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