Linux Commands

What Is XFS Snapshot?

Filesystems are used to store and retrieve the data and metadata. A read-only copy of this complete filesystem is known as a snapshot. A snapshot is a replica of the filesystem (at the time when the system creates the snapshot).

Although snapshots are standard file system copies, many OS users don’t know about them. This guide is for you if you want to know about the XFS snapshot. In this guide, we will provide brief information on the XFS snapshot.

What Is XFS Snapshot?

The Snapshot is the replica of filesystems in any operating system that works as the backup. So you can use xfsdump to create and xfsrestore to restore the backups.

The xfsdump command saves the backup, and it is straightforward. You can write the backup to tape, which contains an XFS backup to create a backup of multiple file systems to the single tape device. Moreover, remember xfsdump can’t overwrite the existing backup, and here is the simple syntax of xfsdump:

sudo xfsdump -f </data/file> <mountpoint>

In the previous command, the -f option was used to define the destination, </data/file> is a file, and the <mountpoint> is the mounting point of the XFS filesystem.

Once you run the command, the terminal will ask you to provide the label to find the dump session. So, you can use the session_0 to check the current session or else the data part for the media label:

The xfsdump command uses the dump level to find the base backup to which another backup is relative. From 0 to 9 refers to the dump levels increment. Incremental backups ensure that the system only backups the files which have changed in the last dump of the lower level. Hence, you can use the level 0 dump to perform the full backup, or please use levels 1 and 2 for the first and second incremental backups. For example, you can run the following command to perform a level 2 backup:

sudo xfsdump -l 2 -L session_2 -M datapart -f </data/file> <mountpoint>

To restore the XFS snapshot backups, you can use the xfsrestore. Here is the basic syntax of this command:

xfsrestore <options> <-S session> <-L session-label>

In the previous syntax, you can add the -r option to restore the file system from the incremental backup. The -s option lets a user choose backup through its session ID, and -L helps choose from the session label.

Conclusion

This tutorial explains everything you need to know about the methods to create XFS snapshots in Linux. We have also presented brief information about the xfsrestore to restore the XFS backups without getting errors. Moreover, we recommend using the commands correctly, or you may get errors while creating backups.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.