Created
April 24, 2011 17:39
-
-
Save click0/939734 to your computer and use it in GitHub Desktop.
Just a small script I wrote to backup mysql via ZFS snapshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Just a small script I wrote to backup mysql via ZFS snapshots | |
#!/bin/sh | |
# Copyright (c) 2011 Vladislav V. Prodan <universite at ukr.net> | |
# My MySQL server uses the directory: | |
# tank/mysql # main directory MySQL | |
# tank/mysql/ibdata # data of InnoDB tables | |
# tank/mysql/iblogs # InnoDB transaction logs | |
/usr/local/bin/mysql -e 'FLUSH LOGS; FLUSH TABLES WITH READ LOCK; \ | |
SYSTEM zfs destroy -r tank/mysql@yesterday; \ | |
SYSTEM zfs rename -r tank/mysql@today @yesterday; \ | |
SYSTEM zfs snapshot -r tank/mysql@today; \ | |
SYSTEM zfs destroy -r tank/mysql/ibdata@yesterday; \ | |
SYSTEM zfs rename -r tank/mysql/ibdata@today @yesterday; \ | |
SYSTEM zfs snapshot -r tank/mysql/ibdata@today; \ | |
SYSTEM zfs destroy -r tank/mysql/iblogs@yesterday; \ | |
SYSTEM zfs rename -r tank/mysql/iblogs@today @yesterday; \ | |
SYSTEM zfs snapshot -r tank/mysql/iblogs@today; \ | |
UNLOCK TABLES;' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment