Snapshots are useful because they can be applied on active file systems. You do not need to have the system in single user mode, nor do you need to unmount the file system you want to backup, as apposed to traditional backups with the standard ufsdump utility.
In the example below, we backup the root file system.
Create the backing store directory on a partition which has preferably at least the same amount of free space as the entire partition size you want to backup. E.g. if your root file system is 500 MB, you will need 500 MB of free space somewhere, no matter how much of that diskspace is actually being used for root file system data. The backing store may also be a raw device. Read the man pages if you want to take risks with sizes.
Create the file system snapshot using the fssnap command:
# fssnap -F ufs -o bs=/somewhere_spacy /
This creates 3 files:
Use the fssnap from /usr/lib/fs/ufs/ with the -i option to get more information about the snapshot; you may want to add this to some kind of log file.
Create a mount point for your snapshot device. Mount it and check that everything is OK:
# mkdir /fssnap # mount -F ufs -o ro /dev/fssnap/0 /fssnap # ls /fssnap --output ommitted--
Backing up the snapshot using tar is also done using the mounted block device:
# cd /fssnap # tar cvf /dev/rmt/0 . --output ommitted--
Of course you can also use ufsdump, on the raw device in that case:
# ufsdump 0uf /dev/rmt/0 /dev/rfssnap/0 --output ommitted--
Test your backup:
# tar tvf /dev/rmt/0 --output ommitted--
for tar, or like this if you used ufsdump:
# ufsrestore tf /dev/rmt/0 --output ommitted--
When you are done making the backup of your snapshot, deactivate it as soon as possible. First unmount the device if you mounted it.
Delete the snapshot:
# fssnap -d /
This will deactivate the freeze of your file system. All changes that were temporarily kept in the backin store file, are now written to the actual file system, which then resumes normal behavior.
Remove the backing store file.
When using ufsdump, you can make incremental backups of snapshots just like you would do in a normal situation. Deactivate the snapshots after every level of backup.