How to configure Time-Slider/autosnap without using the GUI

This is a straight forward process with a twist. The twist is setting an un-obvious ZFS property. Here are the highlights:

  1. Configure Snapshot Properties in SMF repo
  2. Set super secret ZFS property to enable snapshots
  3. Enable related services
  4. Voila!

Okay, here we go. First, let’s dump the manifest and adjust how many one hour snapshots we are going to hold.

# svccfg export auto-snapshot > /tmp/auto-snapshot.smf
# vi /tmp/auto-snapshot.smf

... locate this stanza for the hourly ...

<instance name='hourly' enabled='true'>
<property_group name='zfs' type='application'>
<propval name='interval' type='astring' value='hours'/>
<propval name='keep' type='astring' value='23'/>
<propval name='period' type='astring' value='1'/>
</property_group>
<property_group name='general' type='framework'>
<property name='action_authorization' type='astring'/>
<property name='value_authorization' type='astring'/>
</property_group>
</instance>

I want to hold three days of hourly snapshots. So I changed the value of ‘keep’ from 23 to 71 to hold three days of hourly snapshots. So my stanza looks like this:

<instance name='hourly' enabled='true'>
<property_group name='zfs' type='application'>
<propval name='interval' type='astring' value='hours'/>
<propval name='keep' type='astring' value='71'/>
<propval name='period' type='astring' value='1'/>
</property_group>
<property_group name='general' type='framework'>
<property name='action_authorization' type='astring'/>
<property name='value_authorization' type='astring'/>
</property_group>
</instance>

Okay, great, we have a custom rule set. Now, let’s import it into the SMF repo.

# svccfg import /tmp/auto-snapshot.smf

With the repo updated, we need to set the super secret zfs property and then enable the services. The name of one of my pools is ‘data’ so to set the auto-snapshot property on data I execute this command:

# zfs set com.sun:auto-snapshot=true data

This setting will propagate down so that all the file systems in the pool will have snapshots created for them. By delegating file systems to users with ‘zfs allow -u joe_user data/some/filesystem’ users can control which file systems snapshots will be created for by maintaining their own com.sun:auto-snapshot properties.

Now, let’s review the services and the auto-snap property.

root@db012:~# svcs -a |egrep "auto-snap|slider"
disabled Nov_21 svc:/application/time-slider/plugin:rsync
disabled Nov_21 svc:/application/time-slider/plugin:zfs-send
disabled Nov_21 svc:/system/filesystem/zfs/auto-snapshot:daily
disabled Nov_21 svc:/system/filesystem/zfs/auto-snapshot:frequent
disabled Nov_21 svc:/system/filesystem/zfs/auto-snapshot:hourly
disabled Nov_21 svc:/system/filesystem/zfs/auto-snapshot:monthly
disabled Nov_21 svc:/system/filesystem/zfs/auto-snapshot:weekly
disabled 20:55:28 svc:/application/time-slider:default

root@db012:~# zfs get com.sun:auto-snapshot data
NAME PROPERTY VALUE SOURCE
data com.sun:auto-snapshot - -

So, all the services are off and the property isn’t set. So let’s fix that up now.

# zfs set com.sun:auto-snapshot=true data
# svcadm enable auto-snapshot:hourly
# svcadm enable auto-snapshot:frequently
# svcadm enable time-slider

Now, let’s go check on our handy work…

root@db012:/tmp# zfs get -r creation data/zones |grep @zfs-auto-snap
data/zones@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard0012a.apsalar.com@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard0012a.apsalar.com/local@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard0012a.apsalar.com/mysql@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com/ROOT@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com/ROOT/zbe@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com/apsalar@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com/local@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard009b.apsalar.com/postgres@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/ROOT@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/ROOT/zbe@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/apsalar@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/local@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/mysql@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -
data/zones/shard012a.apsalar.com/postgres@zfs-auto-snap_daily-2011-12-19-21h05 creation Mon Dec 19 21:05 2011 -

Voila! Los Hicimos

If for some reason you didnt get hourly snapshots immediately try restarting the time-slider.


# svcadm restart time-slider

This entry was posted in OpenIndiana, ZFS, ZFS Fun Fact and tagged , , , , . Bookmark the permalink.

5 Responses to How to configure Time-Slider/autosnap without using the GUI

  1. Jim Klimov says:

    Hello, a couple of comments:
    1) Typo nit: in your first example above you missed the “set” keyword (zfs com.sun:auto-snapshot=true data).

    2) You can customize the snapshot policies per-dataset (and its children via inheritance). You can also enable and disable individual snapshot schedules, i.e. I have this policy on the dataset used for automated dumpfiles (and cleaned out regularly to get rid of oldest files):

    # zfs get all pond/export/DUMP/regular | grep auto
    pond/export/DUMP/regular com.sun:auto-snapshot false local
    pond/export/DUMP/regular com.sun:auto-snapshot:weekly true local

    # zfs get all pond/export/DUMP | grep auto
    pond/export/DUMP com.sun:auto-snapshot true inherited from pond

    In particular, you might want to disable snapshots of “rpool/swap” and “rpool/dump”, because these snapshots would be rather useless, but they reserve lots of disk space (as to allow full rewriting of the ZVOL dataset’s contents) greatly reducing your usable rpool space.
    NOTE: this info is valid as of SXCE, I am migrating some systems to OI and will see if the software still works the same way ;)

    HTH,
    //Jim Klimov

  2. Pingback: Configuring the Storage Pools – Building an OpenIndiana based ZFS File Server – part 4 | Experimental and Specialist Computing

  3. Simon Thompson says:

    Hi,

    I think rather than exporting the manifest, editing and reimporting, you should be able to use the following:

    svccfg -s auto-snapshot:daily setprop zfs/keep= astring: ’6′

    • It is certainly possible to edit the config without exporting and re-importing the file. However, I consider it more sophisticated and if someone makes a mistake it will take them longer to figure out how to fix (if at all). Another thing to consider is that exporting the files allows the modification to be checked into a source code repository so that the changes can be tracked in some way.

  4. Yann Ilas says:

    Hi,

    I have a question about the daily auto-snapshot.
    When the line “svc:/system/filesystem/zfs/auto-snapshot:daily” is marked as “enabled”, a daily backup is done. My question : is it possible to schedule the backup at a certain hour ? Or the backup begin when the service is activated ?

    Thank you for your answer.

Leave a Reply

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

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>