Backup and Compress a MySQL Database With One Command
longren.io
longren.io
Example:
#!/bin/bash
TS=$(date "+%Y%m%d-%H%M%S")
SNAP=zpool/mysql@${TS}
zfs snapshot $SNAP
zfs send $SNAP | pv | xz -z | ssh somewhere "cat > /mnt/snapshots/mysql-${TS}.xz"
zfs destroy -Rv $SNAP
Assumes that your /var/lib/mysql is zpool/mysql ofcIf a significant portion of the buffer pool is in memory, it may actually dump quite fast. MySQL 5.5 and above also have a modified LRU algorithm so that tablescans (i.e. mysqldump) can only evict up to 3/8ths of the cache contents.