Table of Contents

Name

snapshot -- UFS2 snapshot management utility

Synopsis

snapshot [options] [command] [arguments]

Description

The snapshot command is a convenience frontend to mount(8) and mdconfig(8) for the management of UFS2 snapshots. It is also the underlying tool used in the periodic snapshot scheduler periodic-snapshot(8) and the mounting/unmouning command in the amd(8) map /etc/amd.map.snap. It provides making, expiring, visiting, mounting and unmounting of filesystem snapshots.

The following global options are available:

-v
Display verbose messages showing the essential system commands involved in the operation.

-h
Display a short usage help message and exit.

-d subdir
Set the subdirectory on filesystems under which snapshots are placed. The default is the conventional .snap subdirectory dump(8) uses, too.

The following commands are available:

snapshot list [fs ...]
List all existing snapshots on all filesystems or just the particular filesystems specified by fs.

snapshot make [-g max-generations] fs:tag[generation] Makes a new snapshot generation named tag on filesystem fs. If the generation part is omitted, generation 0 is used. All older generations (with numbers greater than generation) are rotated and all obsoleted generations (with numbers greater or equal to max-generations) are removed. Keep in mind that a maximum total number of 20 snapshots can be created on a UFS2 filesystem only. A max-generations number of 0 effectively deletes all snapshots on filesystem fs of name tag only.

snapshot mount [-o mount-option] fs:tag[generation] dir Mounts the fs snapshot tag.generation (or tag.0 if generation is omitted) under dir by attaching the snapshot file to the next free md(4) device and mounting this device read-only onto the target directory. If options -o are specified, they are passedthrough to mount(8) .

snapshot umount dir
Unmounts a snapshot by umounting the md(4) device from dir, deattaching the snapshot file from the corresponding md(4) device and deleting the device.

snapshot visit fs:tag[generation]
This is just a convenience command which mounts the specified filesystem on /mnt, temporarily changes to /mnt, starts an interactive shell there for inspecting the snapshot content, and upon exit from the shell immediately unmounts the snapshot again.

Example

The following sample session illustrates the creation, rotation and mounting and cleanup of snapshots:

root# snapshot list /var
root# snapshot -g4 /var:test
/var test.0
root# snapshot -g4 /var:test
/var test.0
/var test.1
root# snapshot -g4 /var:test
/var test.0
/var test.1
/var test.2
root# snapshot -g4 /var:test
/var test.0
/var test.1
/var test.2
/var test.3
root# snapshot -g4 /var:test
/var test.0
/var test.1
/var test.2
/var test.3
root# snapshot mount /var:test.2 /mnt root# ls -l /mnt
root# snapshot umount /mnt
root# snapshot make -g0 /var:test
root# snapshot list /var

By using a amd(8) map /etc/amd.map.snap containing

/defaults type:=program

*
mount:="/usr/sbin/snapshot snapshot mount /${key} ${fs}";\ unmount:="/usr/sbin/snapshot snapshot umount ${fs}"

and a /etc/rc.conf configuration of

amd_enable="YES"
amd_flags="-a /.am -c 1800 -w 60 -l syslog /snap /etc/amd.map.snap"

even non-privileged users can access arbitrary snapshots fs:tag[generation] by just accessing /snap/fs:tag[generation]. For instance, if a snapshot hourly.2 exists on filesystem /var one can then access an old state of file /var/tmp/foo.txt by simply accessing the path /snap/var:hourly.2/tmp/foo.txt.

See Also

mount(8) , mdconfig(8) , md(4) , periodic-snapshot(8) , http://people.freebsd.org/~rse/snapshot/.

History

The snapshot utility first appeared in FreeBSD.

Authors

Ralf S. Engelschall <rse@FreeBSD.org>


Table of Contents