Search code examples
mysqlbackupperconainnobackupex

how can I create incremental backups with xtrabackup automatically


It says on the manual that if you want to create an incremental backup you can do it with the following command:

xtrabackup --backup --target-dir=/data/backups/inc1 \
--incremental-basedir=/data/backups/base --datadir=/var/lib/mysql/

where /data/backups/inc1 is the incremental directory. So now if I want to create a cronjob (which I don't think I'm the only one), I have to figure out a way to name my directory every time I want to create a new incremental backup, which could be tedious.

Is there any way to maje xtrabackup to create directories using timestamps instead?


Solution

  • you can use built-in Linux command date to name directory as you want, for example

    xtrabackup --backup --target-dir=/data/backups/inc`date +%Y%m%d` (rest options)