Updated ZFS Replication and Snapshot Rollup Script
Thanks to the efforts of Ryan Kernan we have an updated ZFS replication and snapshot rollup script. Ryan’s OpenIdiana/Solaris/Illumos community contribution improves the script to allow for a more dynamic source to target pool replication and changes the shapshot retention method to a specific number of snapshots rather than a Grandfather Father Son method.
Regards,
Mike
Site Contents: © 2011 Mike La Spina
Follow me on Twitter
If zfs filesystems with similar name exists in input list the replication fails.
Added @ sign when matching snapshots to allow for similar names.
Regards,
Leif
patch:
*** zfs-replication.sh 2012-02-07 13:06:30.729053500 +0100
— /tmp/zfs-replication.sh 2012-02-07 13:06:09.781167636 +0100
***************
*** 104,110 ****
ssh -n $dhost pfexec zfs create -p $zfspath
ssh -n $dhost pfexec zfs set mountpoint=none $zfspath
! last_snap_shost=$( pfexec zfs list -o name -t snapshot -H | grep $zfspath | tail -1 )
echo $(date) “->” $last_snap_shost Initial replication start. >> replicate.log
pfexec zfs send -v -R $last_snap_shost | ssh $dhost pfexec zfs recv -v -F -d $zfspool
echo $(date) “->” $last_snap_shost Initial replication end. >> replicate.log
— 104,110 —-
ssh -n $dhost pfexec zfs create -p $zfspath
ssh -n $dhost pfexec zfs set mountpoint=none $zfspath
! last_snap_shost=$( pfexec zfs list -o name -t snapshot -H | grep “${zfspath}\@” | tail -1 )
echo $(date) “->” $last_snap_shost Initial replication start. >> replicate.log
pfexec zfs send -v -R $last_snap_shost | ssh $dhost pfexec zfs recv -v -F -d $zfspool
echo $(date) “->” $last_snap_shost Initial replication end. >> replicate.log
***************
*** 165,171 ****
if [ "$zfspath" != "" ]
then
! pfexec zfs list -o name -t snapshot | grep $zfspath > $snap_list
while read snaps
do
— 165,171 —-
if [ "$zfspath" != "" ]
then
! pfexec zfs list -o name -t snapshot | grep “${zfspath}\@” > $snap_list
while read snaps
do