X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=zfs-replicate;h=347bcbe4ad4223872e5450d0b509ebb6d0d88b5c;hb=b2455b4a74638f1a45b29c545c4385f5a219744d;hp=a082ce3fe9de2214ca9d07e2c9dbf5f7fe76ac25;hpb=471f2873d53eebe62223121be58bc3f795511a12;p=zfs-ubuntu%2F.git diff --git a/zfs-replicate b/zfs-replicate index a082ce3..347bcbe 100755 --- a/zfs-replicate +++ b/zfs-replicate @@ -36,9 +36,24 @@ cleanup() { } fatal_and_exit() { echo -e 2>&1 "$1" + # Destroy the backup markers on the local filesystem if they exist + if [[ -n "$current_backup_marker" ]]; then + zfs list -t snapshot ${local_pool}/${current_backup_marker} > /dev/null 2>&1 + if [ $? == 0 ]; then + $zfs destroy ${local_pool}/${current_backup_marker} + fi + fi + if [[ -n "$previous_backup_marker" ]]; then + zfs list -t snapshot ${local_pool}/${previous_backup_marker} > /dev/null 2>&1 + if [ $? == 0 ]; then + $zfs destroy ${local_pool}/${previous_backup_marker} + fi + fi + # send email notification if [[ -n "$2" ]]; then echo -e "$1" | $mailx -s "zfs replicate on $hostname failed" "$2" fi + # exit exit 1 } trap fatal_and_exit INT @@ -162,8 +177,13 @@ if [ $no_markers == 0 ]; then fatal_and_exit "-E- remote incremental $zfs rollback command failed" $mailto fi # Now it should be safe to send the snaps - ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | + $throttle $throttle_opt | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote incremental $zfs send command failed" $mailto fi @@ -182,8 +202,13 @@ else if [[ -n "$common" ]]; then # We found a common snapshot, incrementally send the new snaps - ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | + $throttle $throttle_opt | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote incremental $zfs send command failed" $mailto fi @@ -205,8 +230,13 @@ else fi fi # Send the full filesystem - ssh $remote $zfs send -R ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R ${current_backup_marker} | + $throttle $throttle_opt | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote full $zfs send command failed" $mailto fi