Home | History | Annotate | Download | only in filesystem
      1 <?xml version="1.0"?>
      2 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
      3 <!--
      4 
      5  CDDL HEADER START
      6 
      7  The contents of this file are subject to the terms of the
      8  Common Development and Distribution License, Version 1.0 only
      9  (the "License").  You may not use this file except in compliance
     10  with the License.
     11 
     12  You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     13  or http://www.opensolaris.org/os/licensing.
     14  See the License for the specific language governing permissions
     15  and limitations under the License.
     16 
     17  When distributing Covered Code, include this CDDL HEADER in each
     18  file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     19  If applicable, add the following below this CDDL HEADER, with the
     20  fields enclosed by brackets "[]" replaced with your own identifying
     21  information: Portions Copyright [yyyy] [name of copyright owner]
     22 
     23  CDDL HEADER END
     24 
     25  Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     26  Use is subject to license terms.
     27 
     28 -->
     29 
     30 <service_bundle type='manifest' name='SUNWzfs-auto-snapshot:filesystem-auto-snapshot'>
     31 
     32 <service
     33 	name='system/filesystem/zfs/auto-snapshot'
     34 	type='service'
     35 	version='0.12'>
     36 
     37 	<!-- we need to be multi-user  -->
     38 	<dependency
     39 		name='multi-user'
     40 		grouping='require_all'
     41 		restart_on='none'
     42 		type='service'>
     43 		<service_fmri value='svc:/milestone/multi-user' />
     44 	</dependency>
     45 	
     46 	<!-- we also need cron -->
     47 	<dependency
     48 		name="cron"
     49 		grouping="require_all"
     50 		restart_on="none"
     51 		type="service">
     52 		<service_fmri value="svc:/system/cron" />
     53 	</dependency>
     54 
     55         <exec_method
     56                 type='method'
     57                 name='start'
     58                 exec='/lib/svc/method/zfs-auto-snapshot start'
     59                 timeout_seconds='0'>
     60                         <method_context>
     61                                 <method_credential user='zfssnap' group='daemon' />
     62                         </method_context>
     63         </exec_method>
     64 
     65         <exec_method
     66                 type='method'
     67                 name='stop'
     68                 exec='/lib/svc/method/zfs-auto-snapshot stop'
     69                 timeout_seconds='0' >
     70                         <method_context>
     71                                 <method_credential user='zfssnap' group='daemon' />
     72                         </method_context>
     73         </exec_method>
     74 
     75 	<property_group name='startd' type='framework'>
     76 		<propval name='duration' type='astring' value='transient' />
     77 	</property_group>
     78 
     79         <property_group name='general' type='framework'>
     80             <propval name='action_authorization' type='astring'
     81                 value='solaris.smf.manage.zfs-auto-snapshot' />
     82             <propval name='value_authorization' type='astring'
     83                 value='solaris.smf.manage.zfs-auto-snapshot' />
     84         </property_group>
     85 
     86 
     87 <!-- The properties we expect that any instance will define:
     88 
     89 	fs-name : The name of the filesystem we want to snapshot.
     90 
     91 		The special filesystem name "//" indicates we should
     92 		look at the com.sun:auto-snapshot ZFS user
     93 		properties on datasets, set to "true" if the dataset
     94 		should have snapshots taken by this instance.
     95 	
     96 		If unset, snapshots will not be taken by this instance.
     97 	
     98 		The snapshot-children property is ignored when using
     99 		this setting, instead the system will automatically
    100 		determine how to take snapshots, based on which datasets
    101 		have true, false or unset property values.
    102 
    103 		Setting com.sun:auto-snapshot:<label> will override
    104 		the general setting for com.sun:auto-snapshot.
    105 	
    106 
    107 	interval : minutes | hours | days | months | none
    108 
    109 		For the interval "none" a cron job is not created for that
    110 		instance - instead the user can manually fire the method
    111 		script to take snapshots defined by the rest of the properties
    112 		in the instance. The period and offset values are ignored in
    113 		this case.
    114 
    115 	period : How many (m,h,d,m) do we wait between snapshots
    116 
    117 	offset : The offset into the time period we want
    118 
    119 	keep : How many snapshots we should keep, otherwise, we
    120 		delete the oldest when we hit this threshold
    121 
    122         snapshot-children : Whether we should recursively snapshot
    123 		all filesystems contained within. Ignored when
    124 		using the "//" fs-name value.
    125 
    126 	backup : If we want to perform a "zfs send" for our backup
    127 		we set this - either to "full" or "incremental".
    128 		If set to "none", we don't perform backups.
    129 
    130         backup-save-cmd : A command string to save the backup - if unset,
    131 		we return an error and move the service to
    132 		maintenance.
    133 
    134 	backup-lock : A string we set when a backup operation is in
    135 		progress, to prevent two backups from the same
    136 		service instance running into each other. Not
    137 		completely flawless, but okay. Due to 6338294,
    138 		we use the keyword "unlocked" to indicate that
    139 		the lock is not held.	   
    140 
    141 	label : A string that allows us to differentiate this set
    142 		of snapshot schedules from others configured for the
    143 		same filesystem. This is not usually needed and can
    144 		be left unset, but it can be useful in some 
    145 		situations (particularly for backups).
    146 
    147 	verbose : Set to false by default, setting to true results
    148 		in the service printing more detail in the log
    149 		about what it's doing.
    150 
    151 	avoidscrub : Set to false by default, this determines whether
    152 		we should avoid taking snapshots on any pools that have
    153 		a scrub or resilver in progress.
    154 		More info in the bugid:
    155 		6343667 need itinerary so interrupted scrub/resilver
    156 			doesn't have to start over
    157 
    158 	sep:	Set to '_' by default, this is the character used to
    159 		separate datestamps used in snapshot names.
    160 
    161 	auto-include: Set to 'true' by default, this determines whether
    162 		on startup, we should set a property on all new pools
    163 		seen by the service telling the service to take snapshots
    164 		on that pool. 
    165 
    166 	 -->
    167 	<property_group name="zfs" type="application">
    168 	  <propval name="fs-name" type="astring" value="Not set" override="true"/>
    169 	  <propval name="interval" type="astring" value="Not set" override="true"/>
    170 	  <propval name="offset" type="astring" value="Not set" override="true"/>
    171 	  <propval name="snapshot-children" type="boolean" value="false"
    172 		   override="true"/>
    173 	  <propval name="keep" type="astring" value="all" override="true"/>
    174 
    175 	  <propval name="backup" type="astring" value="none" override="true"/>
    176 	  <propval name="backup-save-cmd" type="astring" value="" override="true"/>
    177 	  <propval name="backup-lock" type="astring" value="unlocked"
    178 		   override="true"/>
    179 
    180 	  <propval name="label" type="astring" value="" override="true"/>
    181 	  <propval name="verbose" type="boolean" value="false" override="true"/>
    182 	  <propval name="avoidscrub" type="boolean" value="false" override="true"/>
    183 	  <propval name="sep" type="astring" value="_" override="true"/>
    184 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    185 	</property_group>
    186 
    187 
    188 	<!-- We now define a set of default instances to take frequent,
    189 	     hourly, daily, weekly and monthly snapshots --> 
    190 
    191 
    192 	<!-- This instance recursively snapshots all
    193      	     filesystems marked with the ZFS User Property 
    194      	     com.sun:auto-snapshot:frequent=true every
    195      	     15 minutes, and keeps 4 of these snapshots into the past.
    196 	-->
    197 
    198 	<instance name='frequent' enabled='false' >
    199 
    200 	<property_group name='general' type='framework'>
    201 		<propval name='action_authorization' type='astring'
    202 		value='solaris.smf.manage.zfs-auto-snapshot' />
    203 		<propval name='value_authorization' type='astring'
    204 		value='solaris.smf.manage.zfs-auto-snapshot' />
    205 	</property_group>
    206 
    207 	<property_group name="zfs" type="application">
    208 
    209 	  <propval name="fs-name" type="astring" value="//" 
    210 		   override="true"/>
    211 	  <propval name="interval" type="astring" value="minutes"
    212 		   override="true"/>
    213 	  <propval name="period" type="astring" value="15"
    214 		   override="true"/>
    215 	  <propval name="offset" type="astring" value="0"
    216 		   override="true"/>
    217 	  <propval name="keep" type="astring" value="4"
    218 		   override="true"/>
    219 	  <propval name="snapshot-children" type="boolean" value="true"
    220 		   override="true"/>
    221 
    222 	  <propval name="backup" type="astring" value="none"
    223 		   override="true"/>
    224 	  <propval name="backup-save-cmd" type="astring" value="not set"
    225 		   override="true"/>
    226 	  <propval name="backup-lock" type="astring" value="unlocked"
    227 		   override="true"/>
    228 
    229 	  <propval name="label" type="astring" value="frequent"
    230 		override="true"/>
    231 
    232 	  <propval name="verbose" type="boolean" value="false"
    233 		override="true"/>
    234 
    235           <propval name="avoidscrub" type="boolean" value="false"
    236 		override="false"/>
    237 
    238 	  <propval name="sep" type="astring" value="_"
    239 		override="true"/>
    240 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    241 
    242 	</property_group>
    243 
    244 	</instance>
    245 
    246 	<!-- This instance recursively snapshots all
    247      	     filesystems marked with the ZFS User Property 
    248      	     com.sun:auto-snapshot:hourly=true every
    249      	     hour, and keeps 24 of these snapshots into the past.
    250 	-->
    251 
    252 	<instance name='hourly' enabled='false' >
    253 
    254 	<property_group name='general' type='framework'>
    255 		<propval name='action_authorization' type='astring'
    256 		value='solaris.smf.manage.zfs-auto-snapshot' />
    257 		<propval name='value_authorization' type='astring'
    258 		value='solaris.smf.manage.zfs-auto-snapshot' />
    259 	</property_group>
    260 
    261 	<property_group name="zfs" type="application">
    262 
    263 	  <propval name="fs-name" type="astring" value="//" 
    264 		   override="true"/>
    265 	  <propval name="interval" type="astring" value="hours"
    266 		   override="true"/>
    267 	  <propval name="period" type="astring" value="1"
    268 		   override="true"/>
    269 	  <propval name="offset" type="astring" value="0"
    270 		   override="true"/>
    271 	  <propval name="keep" type="astring" value="24"
    272 		   override="true"/>
    273 	  <propval name="snapshot-children" type="boolean" value="true"
    274 		   override="true"/>
    275 
    276 	  <propval name="backup" type="astring" value="none"
    277 		   override="true"/>
    278 	  <propval name="backup-save-cmd" type="astring" value="not set"
    279 		   override="true"/>
    280 	  <propval name="backup-lock" type="astring" value="unlocked"
    281 		   override="true"/>
    282 
    283 	  <propval name="label" type="astring" value="hourly"
    284 		   override="true"/>
    285 
    286 	  <propval name="verbose" type="boolean" value="false"
    287 		   override="true"/>
    288 
    289 	  <propval name="avoidscrub" type="boolean" value="false"
    290 		   override="false"/>
    291 
    292 	  <propval name="sep" type="astring" value="_"
    293 		   override="true"/>
    294 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    295 
    296 	</property_group>
    297 
    298 	</instance>
    299 
    300 
    301 	<!-- This instance recursively snapshots all
    302      	     filesystems marked with the ZFS User Property 
    303      	     com.sun:auto-snapshot:daily=true every
    304      	     day, and keeps 31 of these snapshots into the past.
    305 	-->
    306 
    307 	<instance name='daily' enabled='false' >
    308 
    309 	<property_group name='general' type='framework'>
    310 		<propval name='action_authorization' type='astring'
    311 		value='solaris.smf.manage.zfs-auto-snapshot' />
    312 		<propval name='value_authorization' type='astring'
    313 		value='solaris.smf.manage.zfs-auto-snapshot' />
    314 	</property_group>
    315 
    316 	<property_group name="zfs" type="application">
    317 
    318 	  <propval name="fs-name" type="astring" value="//" 
    319 		   override="true"/>
    320 	  <propval name="interval" type="astring" value="days"
    321 		   override="true"/>
    322 	  <propval name="period" type="astring" value="1"
    323 		   override="true"/>
    324 	  <propval name="offset" type="astring" value="0"
    325 		   override="true"/>
    326 	  <propval name="keep" type="astring" value="31"
    327 		   override="true"/>
    328 	  <propval name="snapshot-children" type="boolean" value="true"
    329 		   override="true"/>
    330 
    331 	  <propval name="backup" type="astring" value="none"
    332 		   override="true"/>
    333 	  <propval name="backup-save-cmd" type="astring" value="not set"
    334 		   override="true"/>
    335 	  <propval name="backup-lock" type="astring" value="unlocked"
    336 		   override="true"/>
    337 
    338 	  <propval name="label" type="astring" value="daily"
    339 		   override="true"/>
    340 
    341 	  <propval name="verbose" type="boolean" value="false"
    342 		   override="true"/>
    343 
    344 	  <propval name="avoidscrub" type="boolean" value="false"
    345 		   override="false"/>
    346 
    347 	  <propval name="sep" type="astring" value="_"
    348 		   override="true"/>
    349 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    350 
    351 	</property_group>
    352 
    353 	</instance>
    354 
    355 	<!-- This instance recursively snapshots all
    356      	     filesystems marked with the ZFS User Property 
    357      	     com.sun:auto-snapshot:weekly=true every
    358      	     7 days, and keeps 4 of these snapshots into the past.
    359 	-->
    360 
    361 	<instance name='weekly' enabled='false' >
    362 
    363 	<property_group name='general' type='framework'>
    364 		<propval name='action_authorization' type='astring'
    365 		value='solaris.smf.manage.zfs-auto-snapshot' />
    366 		<propval name='value_authorization' type='astring'
    367 		value='solaris.smf.manage.zfs-auto-snapshot' />
    368 	</property_group>
    369 
    370 	<property_group name="zfs" type="application">
    371 
    372 	  <propval name="fs-name" type="astring" value="//" 
    373 		   override="true"/>
    374 	  <propval name="interval" type="astring" value="days"
    375 		   override="true"/>
    376 	  <propval name="period" type="astring" value="7"
    377 		   override="true"/>
    378 	  <propval name="offset" type="astring" value="0"
    379 		   override="true"/>
    380 	  <propval name="keep" type="astring" value="4"
    381 		   override="true"/>
    382 	  <propval name="snapshot-children" type="boolean" value="true"
    383 		   override="true"/>
    384 
    385 	  <propval name="backup" type="astring" value="none"
    386 		   override="true"/>
    387 	  <propval name="backup-save-cmd" type="astring" value="not set"
    388 		   override="true"/>
    389 	  <propval name="backup-lock" type="astring" value="unlocked"
    390 		   override="true"/>
    391 
    392 	  <propval name="label" type="astring" value="weekly"
    393 		   override="true"/>
    394 
    395 	  <propval name="verbose" type="boolean" value="false"
    396 		   override="true"/>
    397 
    398 	  <propval name="avoidscrub" type="boolean" value="false"
    399 		   override="false"/>
    400 
    401 	  <propval name="sep" type="astring" value="_"
    402 		   override="true"/>
    403 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    404 
    405 	</property_group>
    406 
    407 	</instance>
    408 
    409 
    410 	<!-- This instance recursively snapshots all
    411      	     filesystems marked with the ZFS User Property 
    412      	     com.sun:auto-snapshot:monthly=true every
    413      	     month, and keeps 12 of these snapshots into the past.
    414 	-->
    415 
    416 	<instance name='monthly' enabled='false' >
    417 
    418 	<property_group name='general' type='framework'>
    419 		<propval name='action_authorization' type='astring'
    420 		value='solaris.smf.manage.zfs-auto-snapshot' />
    421 		<propval name='value_authorization' type='astring'
    422 		value='solaris.smf.manage.zfs-auto-snapshot' />
    423 	</property_group>
    424 
    425 	<property_group name="zfs" type="application">
    426 
    427 	  <propval name="fs-name" type="astring" value="//" 
    428 		   override="true"/>
    429 	  <propval name="interval" type="astring" value="months"
    430 		   override="true"/>
    431 	  <propval name="period" type="astring" value="1"
    432 		   override="true"/>
    433 	  <propval name="offset" type="astring" value="0"
    434 		   override="true"/>
    435 	  <propval name="keep" type="astring" value="12"
    436 		   override="true"/>
    437 	  <propval name="snapshot-children" type="boolean" value="true"
    438 		   override="true"/>
    439 
    440 	  <propval name="backup" type="astring" value="none"
    441 		   override="true"/>
    442 	  <propval name="backup-save-cmd" type="astring" value="not set"
    443 		   override="true"/>
    444 	  <propval name="backup-lock" type="astring" value="unlocked"
    445 		   override="true"/>
    446 
    447 	  <propval name="label" type="astring" value="monthly"
    448 		   override="true"/>
    449 
    450 	  <propval name="verbose" type="boolean" value="false"
    451 		   override="true"/>
    452 
    453 	  <propval name="avoidscrub" type="boolean" value="true"
    454 		   override="false"/>
    455 
    456 	  <propval name="sep" type="astring" value="_"
    457 		   override="true"/>
    458 	  <propval name="auto-include" type="boolean" value="true" override="true"/>
    459 
    460 	</property_group>
    461 
    462 	</instance>
    463 
    464 
    465         <!-- This instance takes snapshots on events, rather than
    466 	     being called from cron. Events are tagged by a string
    467 	     argument to the method script. Filesystems marked with
    468              the ZFS User Property com.sun:auto-snapshot:event=true
    469              are included in this schedule. We do not destroy event
    470              driven snapshots, however that can be overridden in the
    471 	     SMF instance properties.
    472         -->
    473 
    474         <instance name='event' enabled='true' >
    475 
    476         <property_group name='general' type='framework'>
    477                 <propval name='action_authorization' type='astring'
    478                 value='solaris.smf.manage.zfs-auto-snapshot' />
    479                 <propval name='value_authorization' type='astring'
    480                 value='solaris.smf.manage.zfs-auto-snapshot' />
    481         </property_group>
    482 
    483         <property_group name="zfs" type="application">
    484 
    485           <propval name="fs-name" type="astring" value="//" 
    486                    override="true"/>
    487           <propval name="interval" type="astring" value="none"
    488                    override="true"/>
    489           <propval name="period" type="astring" value="0"
    490                    override="true"/>
    491           <propval name="offset" type="astring" value="0"
    492                    override="true"/>
    493           <propval name="keep" type="astring" value="all"
    494                    override="true"/>
    495           <propval name="snapshot-children" type="boolean" value="true"
    496                    override="true"/>
    497 
    498           <propval name="backup" type="astring" value="none"
    499                    override="true"/>
    500           <propval name="backup-save-cmd" type="astring" value="not set"
    501                    override="true"/>
    502           <propval name="backup-lock" type="astring" value="unlocked"
    503                    override="true"/>
    504 
    505           <propval name="label" type="astring" value="event"
    506                    override="true"/>
    507 
    508           <propval name="verbose" type="boolean" value="false"
    509                    override="true"/>
    510 
    511           <propval name="avoidscrub" type="boolean" value="true"
    512                    override="false"/>
    513 
    514           <propval name="sep" type="astring" value="_"
    515                    override="true"/>
    516           <propval name="auto-include" type="boolean" value="true" override="true"/>
    517 
    518         </property_group>
    519 
    520         </instance>
    521 
    522 
    523 
    524 
    525 	<stability value='Unstable' />
    526 
    527 	<template>
    528 		<common_name>
    529 			<loctext xml:lang='C'>ZFS automatic snapshots</loctext>
    530 		</common_name>
    531 		<description>
    532 			<loctext xml:lang='C'>
    533 This service provides system support for taking automatic snapshots of ZFS
    534 filesystems.
    535 
    536 In order to use this service, you must create a service instance per set of automatic snapshots you want to take.
    537 
    538 The on starting a service instance, a cron job corresponding to the properties set in the instance is created on the host. This cron job will regularly take snapshots of the specified ZFS filesystem.
    539 
    540 On stopping the service, that cron job is removed.
    541 
    542 We also have the ability to perform backups, done using the "zfs send" command.  A property set in the service called "backup-save-cmd" can be configured as the command used to save the backup stream. See the zfs(1M) man page for an example.  The backups can be either "full" backups, or "incremental" backups - for each incremental backup, a full backup must be configured first. If for some reason an incremental backup fails, a full backup is performed instead.
    543 
    544 By default, snapshots will be taken of any datasets resident on pools that are currently being scrubbed or resilvered. This can behaviour can be changed using the zfs/avoid scrub service property.
    545 
    546 Care should be taken when configuring backups to ensure that the time granularity of the cron job is sufficient to allow the backup to complete between invocations of each backup. We perform locking to ensure that two backups of the same filesystem cannot run simultaneously, but will move the service into "maintenance" state should this occur.
    547 			</loctext>
    548 		</description>
    549 	</template>
    550 </service>
    551 </service_bundle>
    552