Created
May 13, 2011 20:37
-
-
Save click0/971271 to your computer and use it in GitHub Desktop.
Backup method of incremental transfer ZFS partitions from one pool to another within a single machine
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/sh | |
#The initial creation of ZFS partition for further incremental copying | |
pool=zroot #source distination | |
pool2=tank #recipient pool | |
volume2=$pool2/backup/$pool #recipient | |
fs_list='/mysql /usr /usr/ports /usr/src /usr/home /tmp /var /var/crash /var/db /var/db/pkg | |
/var/empty /var/imap /var/imap-cache /var/log /var/mail /var/run /var/tmp'" | |
"`zfs list | grep ^zroot/www | awk ' {print $5}' | tr "\r\n" " "` | |
for fs in "" $fs_list | |
do | |
zfs list -t snapshot $pool${fs}@temp > /dev/null 2>&1 && zfs destroy $pool${fs}@temp | |
zfs list -t snapshot $volume2${fs}@temp > /dev/null 2>&1 && zfs destroy $volume2${fs}@temp | |
echo snapshotting ${fs} | |
zfs snapshot $pool${fs}@temp && | |
( echo snapshop done | |
zfs send $pool${fs}@temp | zfs receive -F $volume2${fs}@temp && | |
( echo sending done | |
zfs rename $pool${fs}@temp $pool${fs}@laststate || exit | |
zfs rename $volume2${fs}@temp $volume2${fs}@laststate || exit | |
echo done for ${fs} ) ) | |
done |
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/sh | |
pool=zroot #source distination | |
pool2=tank #recipient pool | |
volume2=$pool2/backup/$pool #recipient | |
fs_list='/mysql /usr /usr/ports /usr/src /usr/home /tmp /var /var/crash /var/db /var/db/pkg | |
/var/empty /var/imap /var/imap-cache /var/log /var/mail /var/run /var/tmp'" | |
"`zfs list | grep ^zroot/www | awk ' {print $5}' | tr "\r\n" " "` | |
for fs in "" $fs_list | |
do | |
zfs list -t snapshot $pool${fs}@temp > /dev/null 2>&1 && zfs destroy $pool${fs}@temp | |
zfs list -t snapshot $volume2${fs}@temp > /dev/null 2>&1 && zfs destroy $volume2${fs}@temp | |
echo snapshotting ${fs} | |
zfs snapshot $pool${fs}@temp && | |
( echo snapshop done | |
zfs send -vi $pool${fs}@laststate $pool${fs}@temp | zfs receive -Fv $volume2${fs}@temp && | |
( echo sending done | |
zfs destroy $pool${fs}@laststate || exit | |
zfs destroy $volume2${fs}@laststate || exit | |
zfs rename $pool${fs}@temp $pool${fs}@laststate || exit | |
zfs rename $volume2${fs}@temp $volume2${fs}@laststate || exit | |
echo done for ${fs} ) ) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment