Reputation: 159
At the moment I am doing the backup with mysqlbackup. This will call "FLUSH TABLES WITH READ LOCK" and rise the possibility of locking my tables until the flush is done and the global lock released.
So, is there anyway to backup my database, which is really big, there are tables with more than 100 GB, without this global lock ?
Something like mysqldump --single-transaction, which I read is useful on small DBs, which is not the case. Is there sometinh similar appliable to my case ?
Hope so !
Upvotes: 0
Views: 547
Reputation: 603
Percona Xtrabackup is an excellent option when you have tables that large. This is mainly due to the following two points:
a) Time taken to restore a 100GB table from a logical backup (ie: created by mysqldump) would be excessive, since mysql has to rebuild indexes and do a lot of I/O processing as the sql is replayed in.
b) xtrabackup can take incremental backups after you have made your first full backup, making routine nightlies or hourlies much quicker and smaller in terms of disk space.
That said, be aware that because xtrabackup copies all relevant files in the /lib/mysql directory, the diskspace requirements are significant. If you have a database which has 200GB allocated on disk (even if there is some empty allocated space on some tables), your backup will be 200GB in size.
This is compared to mysqldump's logical backup (sql statements which can recreate the data, table structures, indexes etc), which will take up a tiny fraction of the space.
Read more about how Percona xtrabackup works here: https://www.percona.com/doc/percona-xtrabackup/LATEST/how_xtrabackup_works.html
mysqldump used with innodb tables and a combination of --master-data and --single-transaction option is a good option to consider. It acquires a global read lock on all tables, but only for long enough to read the binary log coordinates. Typically this will be very quick, unless there are very significant updates in progress, in which case it could stall until the updates complete.
This gives you a consistent point-in-time backup, and there is no locking beyond the initial read lock.
Here is the syntax:
mysqldump --all-databases --master-data --single-transaction > all_databases.sql
or
mysqldump --master-data --single-transaction my-database > my-database.sql
to back up a single database.
More information about this can be read on the dev.mysql.com site here: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
Upvotes: 0