-
-
Save coldnew/ecfe9b676461af8e72fc to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Capture current date as a variable | |
DATE=`date +"%Y%m%d-%H:%M:%S"` # example output format: 20110925-21:10:36 | |
echo -e "\nRecursively snapshotting storage pool with tag @BACKUP_$DATE" | |
echo "Running 'zfs snapshot -r storage@BACKUP_$DATE'" | |
time zfs snapshot -r storage@BACKUP_$DATE | |
echo -e "\n\nDeleting backups pool to make way for new backup (usually takes a few minutes)." | |
time zfs destroy -r backups | |
echo -e "\n\nSending snapshots to backups pool (this will take a long time. Hours.)" | |
echo "TIP: Run 'zpool iostat backups 1' in another terminal to see how fast the transfer is proceeding." | |
echo "Running 'zfs send -R storage@BACKUP_$DATE | zfs receive -vFd backups'" | |
time zfs send -R storage@BACKUP_$DATE | zfs receive -vFd backups # receive requires -F since backups exists | |
echo -e "\n\nSetting backups pool to readonly (to prevent issues with incremental send/receive later on)" | |
zfs set readonly=on backups # must do this every time as 'zfs destroy -r backups' above removes it | |
ENDTIME=`date +"%Y%m%d-%H:%M:%S"` | |
echo -e "\nFinished at $ENDTIME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment