• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)

By admin

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.

Using xfsdump

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.

Using xfsrestore

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.

How to grow/extend XFS filesytem in CentOS / RHEL using “xfs_growfs” command
Running repairs on XFS Filesystems

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. RPM : package installation Error : cpio: read failed
  2. What is the difference between & (ampersand) and && (double ampersand) while executing simultaneous commands on Linux
  3. Understanding chroot Jail
  4. understanding “yum history” command output
  5. CentOS / RHEL : How to resize (extend) existing Physical Volume (PV)
  6. How To Add New Disk to An Existing Diskgroup on RAC Cluster or Standalone ASM Configuration
  7. Linux / UNIX : Examples of find command to find files with specific sets of permissions
  8. Troubleshooting kdump Issues in CentOS/RHEL
  9. CentOS / RHEL 7 : How to Change Timezone
  10. How to install and configure sosreport under CentOS / RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • What are different Oracle Database Vault Roles
  • Unable to export realm protected table using data pump
  • Beginners Guide to Oracle Database Vault
  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary