XFS uses database journaling technology to provide high reliability and rapid recovery. Recovery after a system crash is completed within a few seconds. XFS is designed for use on most systems from desktop to supercomputer systems. Its major features include:
- Fast & trustable recovery after system crashes because of the use of journaling technology.
- Extremely high I/O performance that scales well on multiprocessing systems.
Using XFS Freeze and EBS Snapshots
xfs_freeze is used to suspend or resume access to an XFS File system thus maintaining consistency. When the filesystem is suspended, all data is flushed to disk and then no IO is allowed on it, which can cause applications using this filesystem to pause, hang and eventually fail.
When performing backup using EBS snapshots, you can freeze the filesystem right before the snapshot is taken, and then unfreeze it right after the snapshot starts. Since EBS snapshots are consistent for their point-in-time, the fact that the IO on the file system continues while the EBS snapshot is still being created does not affect the content of the snapshot.
The actual command to use to freeze the XFS file system is xfs_freeze. xfs_freeze stops new access to the file system and creates a stable image on disk.
The -f flag is used to freeze a specified XFS file system, so that new modifications cannot be undertaken. When the freeze command is applied, all ongoing transactions in the file system are allowed to complete. New write system calls are stopped, and other calls which can modify the file system are stopped. All data, metadata, and log information are written to disk. Any process trying to write to the frozen file system waits till the file system is unfrozen.
The -u flag is used to unfreeze the file system and allow IO to resume. Any file system modifications that were blocked by the freeze are unblocked and allowed to complete.
Using xfs_freeze with N2WS Backup & Recovery (CPM)
N2WS Backup & Recovery (CPM) is an enterprise-class backup and recovery solution for the EC2 cloud. CPM performs backups using AWS EBS snapshots and supports backup scripts to perform quiescence of applications and file systems.
When you activate backup scripts for a backup policy, you provide 3 scripts, the “before” script that is invoked right before the snapshots are taken, the “after” script that is invoked right after the EBS snapshots start, and the “complete” script which is invoked after the snapshots are completed. You can use all 3 scripts or some of them. If you do not need a script, you can provide an empty one that does nothing. Read more about using backup scripts with CPM in CPM’s documentation, specifically in the chapter “Linux/Unix Instances Backup” in the user guide.
In the case of XFS, we need to freeze the file system in the “before” script and unfreeze it in the “after” script. Since the script is invoked on the CPM server and not on the backed-up instance we use SSH to connect to the backed-up instance and perform the operation.
So, the “before” script looks like this:
ssh -i <path to the pem file of the relevant key-pair> <username>@<server address> “sudo xfs_freeze -f <path to the file system mount point>”
if [ $? -gt 0 ]; then
echo “Failed freezing XFS filesystem” 1>&2
echo “xfs freeze succeeded” 1>&2
The “after” script looks similar, except the unfreeze option:
ssh -i <path to the pem file of the relevant key-pair> <username>@<server address> “sudo xfs_freeze -u <path to the file system mount point>”
if [ $? -gt 0 ]; then
echo “Failed unfreezing XFS filesystem” 1>&2
echo “xfs unfreeze succeeded” 1>&2
We direct output to stderr since CPM will collect the output and allow us to view it from the web console.
Since the time span between invoking these two scripts is a few seconds at most, it should not interfere with any operations in the production environment.
Checking for File System Consistency
Finally, after backup you may want to make sure that the backup of the XFS file system is consistent. You can do that by recovering the volume or the entire instance and run the xfs_check command while the device is unmounted.
If the filesystem is on a disk partition, the xfs_check command is:
xfs_check -d partition
partition is the device name for the partition. For example /usr/disk/dsk1
If the filesystem is on an lv logical volume, the xfs_check command is:
xfs_check -d lvvolume
lvvolume is the device file for the logical volume. For example /usr/disk/lv1
xfs_check does not repair any reported filesystem consistency problems, it only reports them.
You can automate the whole test process by using CPM’s CLI (more details here)
To see the different editions with pricing and details, refer to N2Ws’ pricing and purchases page on our website.