Backups in RHEL7

The default storage setup in a new Red Hat Enterprise Linux 7 installation is an LVM partitioning scheme with an XFS boot partition outside of the LVM scheme, and the root and home partitions comprising the main volume group on an XFS filesystem. This is a departure from the previous default filesystem type ext4.
<img alt="RHEL7-partition_scheme" src="https://i1359.photobucket .com/albums/q783/ILMostro7/Web-tech/rhel7-partition_scheme_zps490fabd9.png” title=”RHEL7-partition_scheme”>
Some important behavioral and administrative differences between the ext4 filesystem and the xfs filesystem are addressed in the RedHat Documentation, chapter 6 in the “Storage Administration Guide” specifically. The key items addressed pertain to Filesystem repair, Metadata error behavior, Quotas, Filesystem resize and Inode numbers among other things.
One nice feature of the XFS filesystem is the native backup and restoration feature with the xfsdump and xfsrestore utilities, respectively. The xfsdump utility supports incremental backups to tape drives or regular file images. The incremental backups are possible due to the use of different dump levels. To perform a full backup, a level 0 (zero) dump, of the root (/) filesystem, execute

xfsdump -l 0 -f /dev/tape /

To restore the root filesystem from a locally-mounted tape drive, execute

xfsrestore -f /dev/tape /

There’s a nice write-up about this and other useful features and utilities pertaining to the XFS filesystem on unixarena.com.


Example System Backup

I have an SSD as my primary drive (/dev/sda) with the RHEL7 system installed on 2 physical partitions: boot and the LVM rootfs. I also have a second HDD (/dev/sdb) with partitions for various purposes. I’m going to create a new primary partition of type “Linux LVM” in the free space of /dev/sdb, make it part of a new VolumeGroup with a new Logical Volume, then make the Logical Volume an XFS partition filesystem for backup purposes. Creating the primary partition can be done in a number of different ways, including software with a GUI; I did that with gparted instead of commandline tools, so I’ll skip that part here. As for the remainder of the steps, here it goes:

[04:40][1004]# vgcreate mostrovg /dev/sdb3
  Volume group "mostrovg" successfully created
[04:41][1005]# vgs
  VG             #PV #LV #SN Attr   VSize  VFree 
  mostrovg         1   0   0 wz--n- 24.41g 24.41g
  rhel             1   2   0 wz--n- 77.98g     0
[04:39][1002]# pvs
  PV         VG             Fmt  Attr PSize  PFree 
  /dev/sda5  rhel         lvm2 a--  77.98g     0 
  /dev/sdb3
[04:45][1008]# lvcreate -L 15G mostrovg 
  Logical volume "lvol0" created
[04:46][1009]# lvs
  LV    VG             Attr       LSize  Pool Origin    Data%  Move Log Cpy%Sync Convert
  lvol0 mostrovg       -wi-a----- 15.00g                                             
  home  rhel           -wi-ao---- 27.98g                                             
  root  rhel           -wi-ao---- 50.00g
[04:47][1011]# mkfs.xfs /dev/mostrovg/lvol0 
meta-data=/dev/mostrovg/lvol0    isize=256    agcount=4, agsize=983040 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[04:48][1014]# mkdir /new_xfs
[04:49][1015]# mount -t xfs /dev/mostrovg/lvol0 /new_xfs
[04:49][1016]# df -h /new_xfs
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/mostrovg-lvol0        15G   33M   15G   1% /new_xfs
[04:49][1017]# xfsdump -l 0 -f /new_xfs/redhatsys_xfs_dump /                    [1/848]
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.3 (dump format 3.0) - type ^C for status and control

 ============================= dump label dialog ==============================

please enter label for this dump session (timeout in 300 sec)
 -> first-backup
session label entered: "first-backup"

 --------------------------------- end dialog ---------------------------------

xfsdump: level 0 dump of RedHatSys:/
xfsdump: dump date: Sun Dec 21 04:53:41 2014
xfsdump: session id: 9931f48f-b871-433f-a293-b95a50c0f8f1
xfsdump: session label: "first-backup"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: WARNING: failed to get bulkstat information for inode 12873
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 1156827
xfsdump: WARNING: failed to get bulkstat information for inode 1156827
xfsdump: WARNING: failed to get bulkstat information for inode 1156960
xfsdump: WARNING: failed to get bulkstat information for inode 1160639
xfsdump: WARNING: failed to get bulkstat information for inode 1160642
xfsdump: WARNING: failed to get bulkstat information for inode 68027677
xfsdump: WARNING: failed to get bulkstat information for inode 68027680
xfsdump: WARNING: failed to get bulkstat information for inode 70312711
xfsdump: WARNING: failed to get bulkstat information for inode 70312711
xfsdump: WARNING: failed to get bulkstat information for inode 135342967
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 204649308
xfsdump: WARNING: failed to get bulkstat information for inode 204649308
xfsdump: WARNING: failed to get bulkstat information for inode 204747323
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 7147530560 bytes
xfsdump: /var/lib/xfsdump/inventory created

 ============================= media label dialog =============================

please enter label for media in drive 0 (timeout in 300 sec)
 -> 12212014
media label entered: "12212014"

 --------------------------------- end dialog ---------------------------------

xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 6888970064 bytes
xfsdump: dump size (non-dir files) : 6748694032 bytes
xfsdump: dump complete: 100 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /new_xfs/redhatsys_xfs_dump OK (success)
xfsdump: Dump Status: SUCCESS

Full backup of the root partition finished successfully!

Display the xfsdump inventory to check the possibilities to restore, if needed:

[05:36][1020]# xfsrestore -I
file system 0:
        fs id:          5f6d031e-204b-4c7e-b7e4-96b1bd22a33a
        session 0:
                mount point:    RedHatSys:/
                device:         RedHatSys:/dev/mapper/rhel-root
                time:           Sun Dec 21 04:53:41 2014
                session label:  "first-backup"
                session id:     9931f48f-b871-433f-a293-b95a50c0f8f1
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /new_xfs/redhatsys_xfs_dump
                        start:          ino 134 offset 0
                        end:            ino 208435808 offset 0
                        interrupted:    NO
                        media files:    1
                        media file 0:
                                mfile index:    0
                                mfile type:     data
                                mfile size:     6888970064
                                mfile start:    ino 134 offset 0
                                mfile end:      ino 208435808 offset 0
                                media label:    "12212014"
                                media id:       cb09071b-bb40-4e7d-a268-7232090cad24
xfsrestore: Restore Status: SUCCESS

Great! So, if we wanted, or needed, to restore the filesystem from the previously-listed backup, we’d execute:

xfsrestore -f /new_xfs/redhatsys_xfs_dump -S 9931f48f-b871-433f-a293-b95a50c0f8f1 -r /

Leave a Reply

Your email address will not be published.

*