UFS snaphots

A snapshot is a temporary image of a UFS file system intended for backup operations. Under Solaris we use the fssnap command to create snapshots of UFS file systems.

In a nutshell, fssnap creates a temporary image of a file system by creating a virtual device and a backing store. The virtual device acts like a real device and can be backed up, whilst the backing store file contains copies of the pre-snapshot data that has changed since the creation of the snapshot.

Note: UFS snapshots are not persistent across reboots

For example, when you have a virtual device which was created then the snapshot was taken you can use ufsdump to backup the file system.

In the pre fssnap days, you had to bring the system into single-user mode and then use ufsdump, alternately, break the file system mirror, backup the mirror then reattach the mirror once the backup has completed.

  • Check if any snapshot exists and it's current state (if no output then no snapshots exist.):
    # fssnap -i
  • Take a snapshot of the / (root) file system:
    # fssnap -o bs=/share/snapshots /
    From the above output we see the backing-store is /dev/fssnap/0
  • We can perform a backup of the snapshot, for example:
    # ufsdump -0fu /dev/rmt/0n /dev/fssnap/0
  • Now we can remove the snapshot:
    # fssnap -d /dev/fssnap/0
    Delete snapshot 0.

If you attempt to create any additional snapshots for the same UFS file system, you receive the following error:

# fssnap -o /share/snapshots /
fssnap: Fatal: /share/snapshots/0 already exists.

In this case. you will need to remove the old snapshot in order to create a new one.

Additionally, you can get information on a snapshot using the fssnap -i command, for example:

# fssnap -i
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /
Device state                  : idle
Backing store path            : /share/snapshots/0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Nov 19 16:49:08 2009
Copy-on-write granularity     : 32 KB

Note: Performing a snapshot of the / (root) file system on Solaris can sometimes fail if NTP enabled. Review this article for more information.