Example of MySQL incremental backup with XtraBackup
Percona’s XtraBackup is really good solution for incremental backups if small or large MySQL/MariaDB databases. Mysqldump is really slow and is not downtimeless.
In our case, we need two week history of every day. Every Sunday the backup will be full and the rest of the days, backups will be incremental, based on Sunday’s full backup. The backups will be placed in a folder named current_week. Every Sunday, the folder will be renamed to last_week and new, empty current_week will be created before the full backup.
Here is the script:
It “wants” the day of the week as the first parameter, and the mysql password as a second parameter, like this:
Put it in /usr/local/bin/backup-mysql for example and make it executable. Here is an example cron config, running every day at 2:00 AM: