Use the xfsdump and xfsrestore utilities to back up and restore files in an XFS file system. You can back up files to directly attached tape drives or hard drives, or to remote drives that are accessible over the network. You can back up an entire XFS file system, only the files that have changed since a previous backup, or selected directories or files.
You can restore all files from a full or incremental backup, or selected files and directories. You can restore data to its original location or to another location within an XFS file system. The xfsrestore utility can also be run interactively, allowing you to select files that you want to restore.
Use the “-l [level]” option to specify a full or incremental backup. Level 0 is a full backup of an entire XFS file system. Levels 1-9 are incremental backups that back up all files that have changed since a backup with a lower level number. The following example performs a level 0 backup of the XFS file system mounted on /xfs to a local SCSI tape device, /dev/st0. The –L [session label] option allows you to assign a label to the backup.
# xfsdump –l 0 –L "Level 0 backup of /xfs" –f /dev/st0 /xfs
Backups can span multiple tape media if necessary. If the end of the tape media is reached before the backup is complete, xfsdump prompts you to insert additional media. Multiple backups can also be stored on the same media. The tape is automatically advanced to the end of any existing backups before beginning a new backup.
The following example performs a level 1 backup to a tape device attached to a remote system (host01). Use a colon between the remote host name (or IP address) and the tape device.
# xfsdump –l 1 –f host01:/dev/st0 /xfs
You can also use xfsdump to back up data to a file instead of a tape device. The following example performs a full backup (level 0) of the XFS file system mounted on /xfs to a local file, /usr/tmp/full_Monday. Note that if a level is not specified, a full backup is performed.
# xfsdump –f /usr/tmp/full_Monday /xfs
Use the –s option to back up specific files or directories in an XFS file system. The following example backs up file and directory to a file on a remote host, host01:/usr/tmp/back. Both file and directory are located in the XFS file system mounted on /xfs.
# xfsdump –f host01:/usr/tmp/back –s file –s directory /xfs
Examining xfsdump Inventory
The xfsdump utility keeps an inventory in the /var/lib/xfsdump directory of all backups. You can examine the inventory contents by using the -I option.
# xfsdump –I
The inventory records are in sequential order and are indented for readability and to emphasize the hierarchical nature of the xfsdump information.
The following example restores an xfsdump from a SCSI tape device to an XFS file system mounted on /xfs.
# xfsrestore –f /dev/st0 /xfs
The following example restores the contents of an xfsdump that was written to the /usr/tmp/backup file to the /xfs directory.
# xfsrestore –f /usr/tmp/backup /xfs
You can perform cumulative restores from tape media that contains full (level 0) and incremental backups. Contents of the level 0 xfsdump are restored first, then contents are restored from the next higher level, and so forth until all incremental backups are restored. Use the -r option to perform a cumulative restore.
The following example performs a cumulative restore from xfsdump backups on a SCSI tape device to an XFS file system mounted on /xfs_restore.
# xfsrestore –f /dev/st0 –r /xfs_restore
A cumulative restore creates an xfsrestorehousekeepingdir directory in the directory that is restored. Files in this directory pass information from one execution of xfsrestore to the next. This directory can be removed after the cumulative restore is complete.
Running repairs on XFS Filesystems