Backing up MySQL?
It's easy to dump a db with mysqldump, but because it's not incremental, using rsync over the net becomes hard if you have a lot of data.
Is there a good incremental dump tool for mysql?
4 Replies
Just make sure to flush the logs appropriately, and also make full backups at a certain interval.
1. Run 'mysqladmin refresh' to flush the tables and logs to disk.
2. rsync the MySQL directory (usually something like /var/lib/mysql).
3. Stop MySQL.
4. rsync the MySQL directory again. Since you are only copying the changes since the refresh, this should complete relatively quickly. You know all the files are in a quiescent state as the server is stopped.
5. Start MySQL.
This isn't for heavy-duty sites where uptime is critical and transactions are fast and furious, but is a simple solution for simple sites.
mysqlhotcopy
1. If the database is on an LVM partition and you use InnoDB, you can perform hot snapshot backups using lvm and let InnoDB handle recovery from its logs (if a restore is ever needed).
Setting up InnoDB to have one file per table might ease backups too.
2. You could have a MySQL slave and make your mysqldump backups from that without any write-lock issues.
This second link is simply an awesome resource and mentions both concepts.