Recursive rolling snapshots

Recursive rolling snapshots

With build 63 (Solaris 5.10.6 aka r6) ZFS now supports the recursive snapshot command

my storage pool looks like this

mypool
mypool/home
mypool/home/john
mypool/home/joe

Here is a script to run nightly in cron (note we only snapshot the top directory)
#!/bin/sh
#: jcore
zfs destroy mypool@7daysago 2>&1 > /dev/null
zfs rename -r mypool@6daysago 7daysago 2>&1 > /dev/null
zfs rename -r mypool@5daysago 6daysago 2>&1 > /dev/null
zfs rename -r mypool@4daysago 5daysago 2>&1 > /dev/null
zfs rename -r mypool@3daysago 4daysago 2>&1 > /dev/null
zfs rename -r mypool@2daysago 3daysago 2>&1 > /dev/null
zfs rename -r mypool@yesterday 2daysago 2>&1 > /dev/null
zfs snapshot mypool@yesterday
exit

After running this 7 times this is what I get

# uname -a
SunOS serv10g-dxc1 5.10 Generic_137138-09 i86pc i386 i86pc

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
mypool 9.00G 3.53T 9.00G /mypool
mypool@7daysago 0 – 9.00G –
mypool@6daysago 0 – 9.00G –
mypool@5daysago 0 – 9.00G –
mypool@4daysago 0 – 9.00G –
mypool@3daysago 0 – 9.00G –
mypool@2daysago 0 – 9.00G –
mypool@yesterday 0 – 9.00G –
mypool/home 139K 3.53T 49.7K /mypool/home
mypool/home@7daysago 0 – 49.7K –
mypool/home@6daysago 0 – 49.7K –
mypool/home@5daysago 0 – 49.7K –
mypool/home@4daysago 0 – 49.7K –
mypool/home@3daysago 0 – 49.7K –
mypool/home@2daysago 0 – 49.7K –
mypool/home@yesterday 0 – 49.7K –
mypool/home/joe 44.7K 3.53T 44.7K /mypool/home/joe
mypool/home/joe@7daysago 0 – 44.7K –
mypool/home/joe@6daysago 0 – 44.7K –
mypool/home/joe@5daysago 0 – 44.7K –
mypool/home/joe@4daysago 0 – 44.7K –
mypool/home/joe@3daysago 0 – 44.7K –
mypool/home/joe@2daysago 0 – 44.7K –
mypool/home/joe@yesterday 0 – 44.7K –
mypool/home/john 44.7K 3.53T 44.7K /mypool/home/john
mypool/home/john@7daysago 0 – 44.7K –
mypool/home/john@6daysago 0 – 44.7K –
mypool/home/john@5daysago 0 – 44.7K –
mypool/home/john@4daysago 0 – 44.7K –
mypool/home/john@3daysago 0 – 44.7K –
mypool/home/john@2daysago 0 – 44.7K –
mypool/home/john@yesterday 0 – 44.7K –
#

Leave a Reply

Your email address will not be published. Required fields are marked *