I have a MySQL database with activated binary logging (i.e. rollforward logs). The logs are located (by default) in /var/log/mysql
which is accessible by the users mysql
and root
only.
I make (full) backups every Sunday with a cronjob like this:
mysqldump -u root --flush-logs $database > $database.sql
mysql -u root -e 'purge binary logs before now();'
# or "reset master", which is the same
I know that mysqldump
has no option for incremental backups and the binary logs actually are the incremental backup -- or at least can bee seen as such.
So every Wednesday I make an incremental backup by flushing and copying the binlog files:
mysql -u root -e 'flush binary logs;'
cp /var/log/mysql/mysql-bin.* $some_backup_path
(Code to sort out the current binlog omitted here.)
There are various commands to inspect the binlog files, like
show binary logs; -- display
flush binary logs; -- start a new one
reset master; -- delete all and start over
purge binary logs before $some_date; -- delete older logs
However, there seems to be no MySQL command to fetch them. The only way seems to copy them with "regular" Unix commands, like cp
or rsync
as user root
. Is that true?
I know there are other ways to make backups, such as the MySQL Enterprise stuff or simply backing up the /var/lib/mysql
directory. I'm just curious.