autosnap

autosnap is a command used to schedule snapshots in OviOS Linux. The tool is not available from the ovios shell.

# autosnap --help
Usage: /usr/sbin/autosnap [options] [-l label] <'//' | name [name...]>
  --default-exclude  Exclude datasets if com.ovios:auto-snapshot is unset.
  -d, --debug        Print debugging messages.
  -e, --event=EVENT  Set the com.ovios:auto-snapshot-desc property to EVENT.
      --fast         Use a faster zfs list invocation.
  -n, --dry-run      Print actions without actually doing anything.
  -s, --skip-scrub   Do not snapshot filesystems in scrubbing pools.
  -h, --help         Print this usage message.
  -k, --keep=NUM     Keep NUM recent snapshots and destroy older snapshots.
  -l, --label=LAB    LAB is usually 'hourly', 'daily', or 'monthly'.
  -p, --prefix=PRE   PRE is 'ovios-auto-snap' by default.
  -q, --quiet        Suppress warnings and notices at the console.
      --sep=CHAR     Use CHAR to separate date stamps in snapshot names.
  -g, --syslog       Write messages into the system log.
  -r, --recursive    Snapshot named filesystem and all descendants.
  -v, --verbose      Print info messages.
      --destroy-only Only destroy older snapshots, do not create new ones.
      name           Filesystem and volume names, or '//' for all ZFS datasets.


Examples using autosnap:

1. Take a snapshot of all available datasets in the system

cluster1:~ # autosnap //      
@ovios-auto-snap-2016-08-14-0626, 1 created, 0 destroyed, 0 warnings.
cluster1:~ # zfs list -t snap
NAME                                              USED  AVAIL  REFER  MOUNTPOINT
clpool@ovios-auto-snap-2016-08-14-0626               0      -    19K  -
clpool/cl-lun01@ovios-auto-snap-2016-08-14-0626      0      -     8K  -
clpool/cl-vol01@ovios-auto-snap-2016-08-14-0626      0      -    19K  -
cluster1:~ # 


2. Take a snapshot of a one or more LUNs or Volumes and keep the last 7.

cluster1:~ # autosnap -k 7 clpool/cl-lun01 clpool/cl-vol01
@ovios-auto-snap-2016-08-14-0629, 2 created, 0 destroyed, 0 warnings.
cluster1:~ #


3. Schedule snapshots with a cron job:
- type 'fcrontab -e' to edit the crontab.
- add the autosnap command with the appropriate schedule

In this example it will take a snapshot of all datasets available every minute, and will only keep the 3 latest of each dataset.

cluster1:~ # fcrontab -l
2016-08-14 02:31:50  INFO listing root's fcrontab
PATH=/bin:/sbin:/usr/bin:/usr/sbin
0 3 * * *   /usr/sbin/logrotate /etc/logrotate.conf
* * * * *   /sbin/autosnap -k 3 //

cluster1:~ #