Tille - I can see you, read those man pages!   Tille's Site

File system snapshots in 10 steps

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.

  1. 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.

  2. Create the file system snapshot using the fssnap command:

    # fssnap -F ufs -o bs=/somewhere_spacy /

    This creates 3 files:

    • A big file in the /somewhere_spacy directory. While our actual root file system data are "frozen" so it is safe to make the backup, any changes that happen while the file system is in this frozen state will be written to the backing store file.
    • A raw snapshot device /dev/rfssnap/0 or the first free number if you already have active snapshot devices.
    • A block snapshot device /dev/fssnap/0 or first free number. These devices are images of the actual device that you want to backup.
  3. 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.

  4. 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--
  5. Backing up the snapshot using tar is also done using the mounted block device:

    # cd /fssnap
    # tar cvf /dev/rmt/0 .
    --output ommitted--
  6. Of course you can also use ufsdump, on the raw device in that case:

    # ufsdump 0uf /dev/rmt/0 /dev/rfssnap/0
    --output ommitted--
  7. 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--
  8. When you are done making the backup of your snapshot, deactivate it as soon as possible. First unmount the device if you mounted it.

  9. 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.

  10. 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.

© 1995-2010 Machtelt Garrels - tille - Powered by vIm - Best viewed with your eyes - Validated by W3C - Last update 20100511