Topics: AIX, Backup & restore, Storage, System Admin
JFS2 snapshots
JFS2 filesystems allow you to create file system snapshots. Creating a snapshot is actually creating a new file system, with a copy of the metadata of the original file system (the snapped FS). The snapshot (like a photograph) remains
unchanged, so it's possible to backup the snapshot, while the original data can be used (and changed!) by applications. When data on the original file system changes, while a snapshot exists, the original data is copied to the snapshot to keep the snapshot in a consistant state. For these changes, you'll need temporary space, thus you need to create a snapshot of a specific size to allow updates while the snapshot exists. Usually 10% is enough. Database file systems are usually not a very good subject for creating snapshots, because all database files change constantly when the database is active, causing a lot of copying of data from the original to the snapshot file system.
In order to have a snapshot you have to:
- Create and mount a JFS2 file system (source FS). You can find it in SMIT as "enhanced" file system.
- Create a snapshot of a size big enough to hold the changes of the source FS by issuing smitty crsnap. Once you have created this snapshot as a logical device or logical volume, there's a read-only copy of the data in source FS. You have to mount this device in order to work with this data.
- Mount your snapshot device by issuing smitty mntsnap. You have to provide a directory name over which AIX will mount the snapshot. Once mounted, this device will be read-only.
# snapshot -o snapfrom=$FILESYSTEM -o size=${SNAPSIZE}MWhere $FILESYSTEM is the mount point of your file system and $SNAPSIZE is the amount of megabytes to reserve for the snapshot.
Check if a file system holds a snapshot:
# snapshot -q $FILESYSTEMWhen the snapshot runs full, it is automatically deleted. Therefore, create it large enough to hold all changed data of the source FS.
Mounting the snapshot:
Create a directory:
# mkdir -p /snapshot$FILESYSTEMFind the logical device of the snapshot:
# SNAPDEVICE=`snapshot -q $FILESYSTEM | grep -v ^Snapshots | grep -v ^Current | awk '{print $2}'`Mount the snapshot:
# mount -v jfs2 -o snapshot $SNAPDEVICE /snapshot$FILESYSTEMNow you can backup your data from the mountpoint you've just mounted.
When you're finished with the snapshot:
Unmount the snapshot filesystem:
# unmount /snapshot$FILESYSTEMRemove the snapshot:
# snapshot -d $SNAPDEVICERemove the mount point:
# rm -rf /snapshot$FILESYSTEMWhen you restore data from a snapshot, be aware that the backup of the snapshot is actually a different file system in your backup system, so you have to specify a restore destination to restore the data to.
If you found this useful, here's more on the same topic(s) in our blog:
- Determining memory DIMMs for Linux systems
- Using lvmstat
- Nimesis
- Installation history
- Creating a RAM disk on Linux
Interested in learning more?



