# The snapshot plug-in

A snapshot represents a frozen image of a volume. The source of a snapshot is called an "original." When a snapshot is created, it looks exactly like the original at that point in time. As changes are made to the original, the snapshot remains the same and looks exactly like the original at the time the snapshot was created.

The snapshot feature is very useful for performing data backups. In order to perform a consistent backup, the volume that is being backed up should not change while the backup is running. This often means the volume must be taken offline during the backup, which can be a significant inconvenience to users. With snapshots, the volume can be kept online. A snapshot of the volume is created and the backup is taken from the snapshot, while the original remains in active use.

## How snapshotting is implemented

A snapshot represents a copy of its original volume "frozen" at some point in time. Instead of actually copying all the data from the original to the snapshot, a portion of data is copied only when that portion is being modified on the original. This data portion is called a "chunk."

When data is written to a chunk on the original volume, the snapshot intercepts the I/O request and determines if that chunk has already been saved. If the chunk has not been saved, the chunk is copied from the original to the snapshot, and then the write request is allowed to proceed to the original volume. If additional data is written to that same chunk on the original, the chunk does not need to be copied again.

When data is read from the snapshot, it is the same as when data is read from the original. When a chunk of data is read from the snapshot, the snapshot determines if that chunk has been saved. If it has, the data is retrieved from the snapshot. If the chunk has not been saved, the data is retrieved from the original.

## Creating and activating snapshot objects

Creating and activating a snapshot is a two-step process. The first step is to create the snapshot object. The snapshot object specifies where the saved data will be stored when changes are made to the original. The second step is to activate the object, which is to make an EVMS volume from the object.

### Creating a snapshot

You can create a snapshot object from any unused storage object in EVMS (disks, segments, regions, or feature objects). The size of this consumed object is the size available to the snapshot object. The snapshot object can be smaller or larger than the original volume. If the object is smaller, the original volume could fill up as data is copied from the original to the snapshot, given sufficient activity on the original. In this situation, the snapshot is deactivated and additional I/O to the snapshot fails.

Base the size of the snapshot object on the amount of activity that is likely to take place on the original during the lifetime of the snapshot. The more changes that occur on the original and the longer the snapshot is expected to remain active, the larger the snapshot should be. Clearly, determining this calculation is not simple and requires trial and error to determine the correct snapshot object size to use for a particular situation. The goal is to create a snapshot object large enough to prevent the snapshot from being deactivated if it fills up, yet small enough to not waste disk space. If the snapshot object is the same size as the original volume (actually, a little larger, to account for the snapshot mapping tables), the snapshot is never deactivated.

tells how to create snapshots. The following options are available for creating snapshot objects through the CLI:

original

  The name of the volume to take a snapshot of. Only volumes (EVMS or compatibility) can be snapshotted. Other storage objects cannot be snapshotted.

snapshot

  The name to assign to the new snapshot object.

chunksize

  The granularity of the data that is copied from the original to the snapshot. The default chunksize is 64 KB.

### Activating a snapshot

After you create a snapshot, activate it by making an EVMS volume from the object. After you create the volume and save the changes, the snapshot is active. The only option for activating snapshots is the name to give the EVMS volume. This name can be the same as or different than the name of the snapshot object.

## Other snapshot activities

In addition to creating and activating snapshots, you can also reinitialize them, delete them, and roll them back. The following sections describe these tasks.

### Reinitializing a snapshot

Snapshots can be reinitialized, which causes all of the saved data to be erased and starts the snapshot from the current point in time. A reinitialized snapshot has the same original, chunk size, and writeable flags as the original snapshot.

To reinitialize a snapshot, delete the EVMS volume from the snapshot without deleting the snapshot object. Then create a new EVMS volume from the snapshot object.

### Deleting a snapshot

When a snapshot is no longer needed, you can remove it by deleting the EVMS volume from the snapshot object, and then deleting the snapshot object. Because the snapshot saved the initial state of the original volume (and not the changed state), the original is always up-to-date and does not need any modifications when a snapshot is deleted.

No options are available for deleting snapshots.

### Rolling back a snapshot

Situations can arise where a user wants to restore the original volume to the saved state of the snapshot. This action is called a rollback. One such scenario is if the data on the original is lost or corrupted. Snapshot rollback acts as a quick backup and restore mechanism, and allows the user to avoid a more lengthy restore operation from tapes or other archives.

Another situation where rollback can be particularly useful is when you are testing new software. Before you install a new software package, create a writeable snapshot of the target volume. You can then install the software to the snapshot volume, instead of to the original, and then test and verify the new software on the snapshot. If the testing is successful, you can then roll back the snapshot to the original and effectively install the software on the regular system. If there is a problem during the testing, you can simply delete the snapshot without harming the original volume.

Rollback can only be performed when both the snapshot and the original volumes are unmounted and otherwise not in use. Rollback can also be performed only when there is only a single snapshot of an original. If an original has multiple snapshots, all but the desired snapshot must be deleted before rollback can take place.

No options are available for rolling back snapshots.