Solaris ZFS Administration Guide

Managing Automatic ZFS Snapshots

The Time Slider snapshot tool automatically snapshots ZFS file systems and allows you to browse and recover snapshots of file systems. This tool provides the following features:

You will need to add yourself to the zfssnap role to use the GNOME file manager to modify Time Slider behavior.

When the Time Slider tool is enabled, ZFS file system snapshots are created based on the following criteria:


frequent     snapshots every 15 mins, keeping 4 snapshots
hourly	     snapshots every hour, keeping 24 snapshots
daily	     snapshots every day, keeping 31 snapshots
weekly	     snapshots every week, keeping 7 snapshots
monthly	     snapshots every month, keeping 12 snapshots

ProcedureHow to Manage Automatic ZFS Snapshots

  1. Start a privileged shell, if running an OpenSolaris release. Otherwise, become a privileged user.


    user@opensolaris:-$ pfexec bash
    #

    In this example, the bash shell is selected. You can choose to use any shell with the pfexec command. If you support multiple versions of the SolarisTM OS, use the standard su root command. The su command works on all Solaris versions.

  2. Enable the Time Slider service, which is disabled by default.

    You can enable or disable these services from the command line or from the System->Preferences->Time Slider Setup menu. From this menu, you can also customize which ZFS file systems to snapshot and adjust the file system capacity setting for when snapshots are removed.

  3. Review the default automatic snapshot service instances that are started when the Time Slider service is enabled.


    # svcs | grep auto-snapshot
    online       Oct_22   svc:/system/filesystem/zfs/auto-snapshot:frequent
    online       Oct_22   svc:/system/filesystem/zfs/auto-snapshot:hourly
    online       Oct_22   svc:/system/filesystem/zfs/auto-snapshot:weekly
    online       Oct_22   svc:/system/filesystem/zfs/auto-snapshot:monthly
    online       Oct_22   svc:/system/filesystem/zfs/auto-snapshot:daily
  4. Confirm that automatic snapshots are created.

    For example:


    # zfs list -t snapshot
    NAME                                                   USED  AVAIL  REFER  MOUNTPOINT
    rpool@zfs-auto-snap:weekly-2008-11-13-15:39            0      -     46.5K  -
    rpool@zfs-auto-snap:daily-2008-11-13-15:39             0      -     46.5K  -
    rpool@zfs-auto-snap:hourly-2008-11-13-15:39            0      -     46.5K  -
    rpool@zfs-auto-snap:frequent-2008-11-13-15:39          0      -     46.5K  -
    rpool/ROOT@zfs-auto-snap:weekly-2008-11-13-15:39       0      -     18K  -
    rpool/ROOT@zfs-auto-snap:daily-2008-11-13-15:39        0      -     18K  -
    rpool/ROOT@zfs-auto-snap:hourly-2008-11-13-15:39       0      -     18K  -
    rpool/ROOT@zfs-auto-snap:frequent-2008-11-13-15:39     0      -     18K  -
    .
    .
    .
  5. Disable or enable specific automatic snapshot services for the top-level dataset and all descendent datasets from the command line.

    For example:


    # zfs set com.sun:auto-snapshot=false rpool
    # zfs set com.sun:auto-snapshot=true rpool/ROOT/opensolaris
  6. Choose to only take snapshots under a given schedule for a dataset and all direct descendent datasets from the command line.

    For example:


    # zfs set com.sun:auto-snapshot=false rpool/export
    # zfs set com.sun:auto-snapshot:weekly=true rpool/export
  7. Change the frequency of a given snapshot schedule from the command line.

    For example:


    # svccfg -s svc:/system/filesystem/zfs/auto-snapshot:frequent setprop zfs/period = 30
    # svccfg -s svc:/system/filesystem/zfs/auto-snapshot:frequent refresh
    # svcadm restart svc:/system/filesystem/zfs/auto-snapshot:frequent
  8. Disable automatic snapshot services for the swap and dump volumes, from the command line, if necessary.

    For example:


    # zfs set com.sun:auto-snapshot=false rpool/dump
    # zfs set com.sun:auto-snapshot=false rpool/swap
  9. Remove a range of unwanted snapshots, from the command line, if necessary.

    For example, remove all automatic snapshots in the bash shell, as follows:


    for s in `zfs list -H -o name -t snapshot | grep @zfs-auto-snap`; 
    do zfs destroy $s; done

ProcedureHow to Recover Automatic ZFS Snapshots (GNOME File Manager)

You can browse and recover snapshots from the GNOME desktop file manager, which is accessed as follows:

  1. Browse your snapshots by opening any folder in the GNOME file manager.

    If the Restore icon (clock with slider ) is enabled, snapshots of this directory are available.

  2. Click on the clock icon to access snapshot navigation features.

    Directly below the location: URL section is a one line description of the following information:

    • The timeline or date and time that the snapshot was taken

    • The location in the backup timeline of the current snapshot

    • The number of snapshots available for this directory and the space consumed by ZFS snapshots

  3. Drag the slider into the past to retrieve previous versions of your files.

    You can open all your files in read-only mode. Or, you can browse in list view mode (as oppose to icon view) so that a restore information column automatically appears. This column gives you contextual information about either of the following:

    • The file version number, if you browse in the current or latest version of a directory

    • The difference, if any, between the file snapshot and the latest version of the file

  4. Recover files from an automatic snapshot from either of the following methods:

    • Drag and drop a snapshot into another file manager window

    • Right click the mouse and select the restore to Desktop icon. Then, copy and paste the selected snapshot to the present time.