Autosnap Guide
"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
ovios-indt:~ # autosnap //
@ovios-auto-snap-2020-10-19-1356, 1 created, 0 destroyed, 0 warnings.
ovios-indt:~ #
Now you can list all the snapshots in the shell:
ovios-indt:~ # exit
ovios-shell> snap list
List snapshot for a specific volume? If not, all will be listed. (Default: list ALL) [y | n]
NAME USED CREATION
OVIOSPOOL@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
OVIOSPOOL/lun01@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
OVIOSPOOL/lun02@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
OVIOSPOOL/nfsvol@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
OVIOSPOOL/osbackup@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
OVIOSPOOL/smbvol@ovios-auto-snap-2020-10-19-1356 0B Mon Oct 19 13:56 2020
ovios-shell>
2. Take a snapshot of a one or more LUNs or Volumes and keep the last 7.
ovios-indt:~ # autosnap -g -r -k 7 OVIOSPOOL/lun01 OVIOSPOOL/smbvol
@ovios-auto-snap-2020-10-19-1358, 2 created, 0 destroyed, 0 warnings.
ovios-indt:~ #
In this example we take new snapshots for lun01 and smbvol, and keep the last 7 snapshots.
3. Schedule snapshots with a cron job:
In this example it will take a snapshot of all datasets available every minute, and will only keep the 3 latest of each dataset.
ovios-shell> edit_cron vim
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 //