System Administration Guide: Devices and File Systems

Chapter 26 Using UFS Snapshots (Tasks)

This chapter describes how to create and back up UFS snapshots.

For information on the procedures associated with creating UFS snapshots, see Using UFS Snapshots (Task Map).

For overview information about performing backups, see Chapter 24, Backing Up and Restoring UFS File Systems (Overview).

Using UFS Snapshots (Task Map)

Task 

Description 

For Instructions 

1. Create a UFS snapshot. 

Create a read-only copy of a file system by using the fssnap command.

How to Create a UFS Snapshot

2. Display UFS snapshot information. 

Identify UFS snapshot information such as the raw snapshot device. 

How to Display UFS Snapshot Information

3. (Optional) Delete a UFS snapshot. 

Delete a snapshot that is already backed up or no longer needed. 

How to Delete a UFS Snapshot

4. (Optional) Back up a UFS snapshot. 

Choose one of the following backup methods: 

 

 

Create a full backup of a UFS snapshot by using the ufsdump command.

How to Create a Full Backup of a UFS Snapshot (ufsdump)

 

Create an incremental backup of a UFS snapshot by using the ufsdump command.

 

How to Create an Incremental Backup of a UFS Snapshot (ufsdump)

 

Back up a UFS snapshot by using the tar command.

How to Back Up a UFS Snapshot (tar)

5. (Optional) Restore data from a UFS snapshot. 

Restore the UFS snapshot the same way as you would restore data by using the ufsrestore command.

How to Restore a Complete UFS File System

UFS Snapshots Overview

You can use the fssnap command to back up file systems while the file system is mounted. This command to creates a read-only snapshot of a file system. A snapshot is a file system's temporary image that is intended for backup operations.

When the fssnap command is run, it creates a virtual device and a backing-store file. You can back up the virtual device, which looks and acts like a real device, with any of the existing Solaris backup commands. The backing-store file is a bitmap file that contains copies of pre snapshot data that has been modified since the snapshot was taken.

Keep the following key points in mind when specifying backing-store files:

For more information about creating snapshots for a UFS file system larger than 512 Gbytes, see Creating a Multiterabyte UFS Snapshot.

Why Use UFS Snapshots?

The UFS snapshots feature provides additional availability and convenience for backing up a file system because the file system remains mounted and the system remains in multiuser mode during backups. Then, you can use the tar or cpio commands to back up a UFS snapshot to tape for more permanent storage. If you use the ufsdump command to perform backups, the system should be in single-user mode to keep the file system inactive when you perform backups.

The fssnap command gives administrators of non enterprise-level systems the power of enterprise-level tools, such as Sun StorEdgeTM Instant Image, without the large storage demands.

The UFS snapshots feature is similar to the Instant Image product. Although UFS snapshots can make copies of large file systems, Instant Image is better suited for enterprise-level systems. UFS snapshots is better suited for smaller systems. Instant Image allocates space equal to the size of the entire file system that is being captured. However, the backing-store file that is created by UFS snapshots occupies only as much disk space as needed.

This table describes specific differences between UFS snapshots and Instant Image.

UFS Snapshots 

Sun StorEdge Instant Image 

Size of the backing-store file depends on how much data has changed since the snapshot was taken 

Size of the backing-store file equals the size of the entire file system being copied 

Does not persist across system reboots 

Persists across system reboots 

Works on UFS file systems 

Cannot be used with root (/) or /usr file systems

Available starting with the Solaris 8 1/01 release 

Part of Sun StorEdge products 

UFS Snapshots Performance Issues

When the UFS snapshot is first created, users of the file system might notice a slight pause. The length of the pause increases with the size of the file system to be captured. While the snapshot is active, users of the file system might notice a slight performance impact when the file system is written to. However, they see no impact when the file system is read.

Creating and Deleting UFS Snapshots

When you use the fssnap command to create a UFS snapshot, observe how much disk space the backing-store file consumes. The backing-store file initially uses no space, and then it grows quickly, especially on heavily used systems. Make sure that the backing-store file has enough space to expand. Or, limit its size with the -o maxsize=n [k,m,g] option, where n [k,m,g] is the maximum size of the backing-store file.


Caution – Caution –

If the backing-store file runs out of space, the snapshot might delete itself, which causes the backup to fail. Check the /var/adm/messages file for possible snapshot errors.


You can also specify a directory for the backing-store path, which means a backing store file is created in the directory specified. For example, if /var/tmp is specified for the backing-store path, the following backing-store file is created.


/var/tmp/snapshot0

If you created one large root (/) file system instead of creating separate file systems for /export/home, /usr, and so on, you will be unable to create a snapshot of those separate file systems. For example, this system does not have a separate file system for /usr as indicated under the Mounted on column:


# df -k /usr
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c0t0d0s0    3618177 2190002 1391994    62%    /

If you attempt to create a snapshot for the /usr file system, you will see a message similar to the following:


# fssnap -F ufs -o bs=/snaps/usr.back.file /usr
snapshot error: Invalid backing file path

This message indicates that you cannot have the backing store file on the same file system as the file system being snapped, which is the case for the /usr file system, in this example.

For more information, see the fssnap_ufs(1M) man page.

Creating a Multiterabyte UFS Snapshot

Creating a multiterabyte UFS snapshot is identical to creating a snapshot for a smaller UFS file system. The only difference is that multiple backing store files are created for each 512 Gbytes of file system space.

Keep the following key points in mind when creating a snapshot for a file system that is larger than 512 Gbytes:

For an example of creating a snapshot for a file system that is larger than 512 Gbytes, see Example 26–2.

For more information, see fssnap_ufs(1M).

ProcedureHow to Create a UFS Snapshot

  1. Become superuser or assume an equivalent role.

  2. Make sure that the file system has enough disk space for the backing-store file.


    # df -k 
    
  3. Make sure that a backing-store file of the same name and location does not already exist.


    # ls /backing-store-file
    
  4. Create the UFS snapshot.


    # fssnap -F ufs -o bs=/backing-store-file /file-system
    

    Note –

    The backing-store file must reside on a different file system than the file system that is being captured using UFS snapshots.


  5. Verify that the snapshot has been created.


    # /usr/lib/fs/ufs/fssnap -i /file-system
    

Example 26–1 Creating a UFS Snapshot

The following example shows how to create a snapshot of the /usr file system. The backing-store file is /scratch/usr.back.file. The virtual device is /dev/fssnap/1.


# fssnap -F ufs -o bs=/scratch/usr.back.file /usr
/dev/fssnap/1

The following example shows how to limit the backing-store file to 500 Mbytes.


# fssnap -F ufs -o maxsize=500m,bs=/scratch/usr.back.file /usr 
/dev/fssnap/1


Example 26–2 Creating a Multiterabyte UFS Snapshot

The following example shows how to create a snapshot of a 1.6 Tbyte UFS file system.


# fssnap -F ufs -o bs=/var/tmp /datab
/dev/fssnap/2
# /usr/lib/fs/ufs/fssnap -i /datab
Snapshot number               : 2
Block Device                  : /dev/fssnap/2
Raw Device                    : /dev/rfssnap/2
Mount point                   : /datab
Device state                  : idle
Backing store path            : /var/tmp/snapshot3
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Wed Jul 16 14:43:32 2008
Copy-on-write granularity     : 32 KB

ProcedureHow to Display UFS Snapshot Information

You can display the current snapshots on the system by using the fssnap -i option. If you specify a file system, you see detailed information about that file system snapshot. If you don't specify a file system, you see information about all of the current UFS snapshots and their corresponding virtual devices.


Note –

Use the UFS file system-specific fssnap command to view the extended snapshot information as shown in the following examples.


  1. Become superuser or assume an equivalent role.

  2. List all current snapshots.

    For example:


    # /usr/lib/fs/ufs/fssnap -i
    Snapshot number               : 0
    Block Device                  : /dev/fssnap/0
    Raw Device                    : /dev/rfssnap/0
    Mount point                   : /export/home
    Device state                  : idle
    Backing store path            : /var/tmp/snapshot0
    Backing store size            : 0 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Jul 16 14:30:24 2008
    Copy-on-write granularity     : 32 KB
  3. Display detailed information about a specific snapshot.

    For example:


    # /usr/lib/fs/ufs/fssnap -i /export
    Snapshot number               : 1
    Block Device                  : /dev/fssnap/1
    Raw Device                    : /dev/rfssnap/1
    Mount point                   : /export
    Device state                  : idle
    Backing store path            : /var/tmp/snapshot1
    Backing store size            : 0 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Jul 16 14:34:47 2008
    Copy-on-write granularity     : 32 KB

Deleting a UFS Snapshot

When you create a UFS snapshot, you can specify that the backing-store file is unlinked. An unlinked backing-store file is removed after the snapshot is deleted. If you don't specify the -o unlink option when you create a UFS snapshot, you must manually delete the backing-store file.

The backing-store file occupies disk space until the snapshot is deleted, whether you use the -o unlink option to remove the backing-store file or you manually delete the file.

ProcedureHow to Delete a UFS Snapshot

You can delete a snapshot either by rebooting the system or by using the fssnap -d command. When you use this command, you must specify the path of the file system that contains the UFS snapshot.

  1. Become superuser or assume an equivalent role.

  2. Identify the snapshot to be deleted.


    # /usr/lib/fs/ufs/fssnap -i
    
  3. Delete the snapshot.


    # fssnap -d /file-system
    Deleted snapshot 1.
  4. If you did not use the -o unlink option when you created the snapshot, manually delete the backing-store file.


    # rm /file-system/backing-store-file
    

Example 26–3 Deleting a UFS Snapshot

The following example shows how to delete a snapshot and assumes that the -o unlink option was not used.


# fssnap -i
    0    /export/home
    1    /export
   # fssnap -d /export
 Deleted snapshot 1.
# rm /var/tmp/snapshot1

Backing Up a UFS Snapshot

You can create a full backup or an incremental backup of a UFS snapshot. You can use the standard Solaris backup commands to back up a UFS snapshot.

The virtual device that contains the UFS snapshot acts as a standard read-only device. So, you can back up the virtual device as if you were backing up a file system device.

If you are using the ufsdump command to back up a UFS snapshot, you can specify the snapshot name during the backup. See the following procedure for more information.

ProcedureHow to Create a Full Backup of a UFS Snapshot (ufsdump)

  1. Become superuser or assume an equivalent role.

  2. Identify the UFS snapshot to be backed up.


    # /usr/lib/fs/ufs/fssnap -i /file-system
     
    

    For example:


    # /usr/lib/fs/ufs/fssnap -i /usr
    Snapshot number               : 1
    Block Device                  : /dev/fssnap/1
    Raw Device                    : /dev/rfssnap/1
    Mount point                   : /usr
    Device state                  : idle
    Backing store path            : /var/tmp/snapshot2
    Backing store size            : 544 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Jul 16 14:38:29 2008
    Copy-on-write granularity     : 32 KB
  3. Back up the UFS snapshot.


    # ufsdump 0ucf /dev/rmt/0 /snapshot-name
    

    For example:


    # ufsdump 0ucf /dev/rmt/0 /dev/rfssnap/1 
    
  4. Verify that the snapshot has been backed up.

    For example:


    # ufsrestore tf /dev/rmt/0
    

ProcedureHow to Create an Incremental Backup of a UFS Snapshot (ufsdump)

Backing up a UFS snapshot incrementally means that only the files that have been modified since the last snapshot are backed up. Use the ufsdump command with the N option. This option specifies the file system device name to be inserted into the /etc/dumpdates file for tracking incremental dumps.

The following ufsdump command specifies an embedded fssnap command to create an incremental backup of a file system.

  1. Become superuser or assume an equivalent role.

  2. Create an incremental backup of a UFS snapshot.

    For example:


    # ufsdump 1ufN /dev/rmt/0 /dev/rdsk/c0t1d0s0 `fssnap -F ufs -o raw,bs=
    /export/scratch,unlink /dev/rdsk/c0t1d0s0`
    

    In this example, the -o raw option is used to display the name of the raw device instead of the block device. By using this option, you make it easier to embed the fssnap command in commands (such as the ufsdump command) that require the raw device instead.

  3. Verify that the snapshot has been backed up.


    # ufsrestore ta /dev/rmt/0
    

ProcedureHow to Back Up a UFS Snapshot (tar)

If you are using the tar command to back up the snapshot, mount the snapshot before backing it up.

  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the snapshot.

    For example:


    # mkdir /backups/home.bkup
    
  3. Mount the snapshot.


    # mount -F ufs -o ro /dev/fssnap/1 /backups/home.bkup
    
  4. Change to the mounted snapshot directory.


    # cd /backups/home.bkup
    
  5. Back up the snapshot with the tar command.


    # tar cvf /dev/rmt/0 .
    

Restoring Data From a UFS Snapshot Backup

The backup created from the virtual device is essentially just a backup of what the original file system looked like when the snapshot was taken. When you restore a file system from the backup, restore as if you had taken the backup directly from the original file system. Such a restore uses the ufsrestore command. For information on using the ufsrestore command to restore a file or file system, see Chapter 27, Restoring UFS Files and File Systems (Tasks).