Skip to content

ZFS snapshot on boot

November 18, 2005

ZFS hits my Toshiba laptop and so I have moved the home directories onto a zfs file system.

The big advantage for me is that I can now have the system snapshot the filesystem each time it boots. First this script does the work:

 #!/bin/ksh -p date=$(date ‘+%F-%T’)  for fs in $(zfs list -H -o name -t filesystem) do         zfs snapshot ${fs}@${date} done 

And this manifest gets it to be run:

 <?xml version=”1.0″?>  <!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1”>  <service_bundle type=’manifest’ name=’snapshot’>  <service         name=’system/filesystem/snapshot’         type=’service’         version=’1′>          <create_default_instance enabled=’true’ />          <dependency                 name=’filesystem’                 grouping=’require_all’                 restart_on=’none’                 type=’service’>                 <service_fmri value=’svc:/system/filesystem/local’ />         </dependency>          <exec_method                 type=’method’                 name=’start’                 exec=’/mypool/root/snapshot’                 timeout_seconds=’10’ />          <exec_method                 type=’method’                 name=’stop’                 exec=’:true’                 timeout_seconds=’3′ />          <property_group name=’startd’ type=’framework’>                 <propval name=’duration’ type=’astring’ value=’transient’/>         </property_group>  </service> </service_bundle> 

Now import the manifest into smf:

  # svccfg import  snapshot.xml 

Now I get a snapshot of the home directories everytime I reboot. These are mounted under .zfs/snapshot so users can pull back anything they need when they want to. Just what you want from a file system.

Tags: topic:[OpenSolaris], topic:[Solaris], topic:[ZFS], topic:[smf]

Advertisements

From → Solaris

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: