Going back in time with ZFS
By hugo on Nov 17, 2008
With ZFS, taking and storing snapshots has become a very lightweight operation: they can be created almost instantly, and initially consume no additional disk space. Many Solaris users have created their own scripts to implement a backup policy based on them. So it seems natural to provide this as a standard OS service. Tim Foster has done just that, providing five SMF services to capture ZFS snapshots at regular intervals:
$ svcs auto-snapshot
STATE STIME FMRI
online 9:27:35 svc:/system/filesystem/zfs/auto-snapshot:weekly
online 9:27:39 svc:/system/filesystem/zfs/auto-snapshot:monthly
online 9:27:39 svc:/system/filesystem/zfs/auto-snapshot:hourly
online 9:27:39 svc:/system/filesystem/zfs/auto-snapshot:daily
online 9:27:40 svc:/system/filesystem/zfs/auto-snapshot:frequent
The default settings for frequency and retention policies are:
- frequent: snapshots every 15 mins, keeping the last 4
- hourly: snapshots every hour, keeping the last 24
- daily: snapshots every day, keeping the last 31
- weekly: snapshots every week, keeping the last 4
- monthly: snapshots every month, keeping the last 12
How do you turn this on? While this could be done by setting the com.sun:auto-snapshot property to true on the target file system(s), there's a Time Slider Setup GUI (under System/Administration in the menu) to make things easier. You can choose to run auto-snapshots for all file systems, or select individual ones. For the icing on the cake, a time slider has been integrated into GNOME's Nautilus file manager, so you can "travel back in time" to see individual files from any of your snapshots. See Erwann's Chénedé's blog for details, including screen shots.
I often need to recover older version of documents to undo recent changes, only to discover that I forgot to save a copy. If you're like me, these new tools are a great time saver. Turn the service on, and let it do the work for you.
Note: In the OpenSolaris 2008.11 development builds (snv_101a_rc1b in my case) there is an issue with the zfssnap role not being able to run cron jobs. If you try this on early access bits, apply the changes suggested here. Check the services' logs at /var/svc/log/ for troubleshooting.