6.10.2.3 Method 3: Back Up a Guest Internally
You can take a snapshot-based backup of a guest from inside the guest.
All steps are performed from inside the guest.
Note:
This backup method is performed internally within the guest and
uses logical volume snapshots. Compared with other backup methods, this method provides more
limited recovery options because the backup is only useful when the guest is bootable and allows root user login.
This procedure backs up the contents of all currently active file systems in the guest. Before starting, ensure that all of the file systems that you want to back up are mounted.
The values shown in the following steps are examples and you may need to substitute different values to match your situation.
All steps must be performed as the root user.
- Prepare a destination to hold the backup.
The destination should reside outside of the local machine, such as a writable NFS location, and be large enough to hold the backup. For non-customized partitions, the space needed for holding the backup is approximately 60 GB.
You can use the following commands to prepare a backup destination using NFS.
# mkdir -p /root/remote_FS # mount -t nfs -o rw,intr,soft,proto=tcp,nolock ip_address:/nfs_location/ /root/remote_FSIn the
mountcommand, ip_address is the IP address of the NFS server, and nfs_location is the NFS location holding the backups. - Remove the
LVDoNotRemoveOrUselogical volume.The logical volume
/dev/VGExaDb/LVDoNotRemoveOrUseis a placeholder to make sure there is always free space available to create a snapshot.Before Oracle Exadata System Software release 25.2, the
LVDoNotRemoveOrUselogical volume occupies 2 GB of space in theVGExaDbvolume group. Starting with Oracle Exadata System Software release 25.2, theLVDoNotRemoveOrUselogical volume occupies all of the available free space (typically between 2 GB and 3 GB) in theVGExaDbvolume group after the creation of all the necessary system logical volumes.Use the following script to check for the existence of the
LVDoNotRemoveOrUselogical volume and remove it if present.lvm lvdisplay --ignorelockingfailure /dev/VGExaDb/LVDoNotRemoveOrUse if [ $? -eq 0 ]; then # LVDoNotRemoveOrUse logical volume exists. lvm lvremove -f /dev/VGExaDb/LVDoNotRemoveOrUse if [ $? -ne 0 ]; then echo "Cannot remove logical volume: LVDoNotRemoveOrUse. Do not proceed with backup." fi fiIf the
LVDoNotRemoveOrUselogical volume does not exist, then do not proceed with the remaining steps and determine the reason. - Gather information about the currently active file systems and logical volumes.
In this step, you must gather information from your guest to use later in the commands that create the logical volume snapshots and backup files.
Run the following command:
# df -hT | grep VGExaFor every entry in your command output, determine the following information and create a table of values to use later:
-
The volume group (VG) name and logical volume (LV) name are contained in the file system name as follows:
/dev/mapper/VG-name-LV-nameFor example, in
/dev/mapper/VGExaDb-LVDbHome, the VG name isVGExaDband the LV name isLVDbHome. - The backup label is a string that identifies the file system and its backup file. Use
rootfor the root (/) file system. Otherwise, you can use a string that concatenates the directories in the mount point. For example, you can usevarlogauditfor/var/log/audit. - Define a short label, which contains 12 or fewer characters. You will use the short label to label the snapshot file system.
For example:
# df -hT | grep VGExa /dev/mapper/VGExaDb-LVDbSys1 xfs 15G 4.2G 11G 28% / /dev/mapper/VGExaDb-LVDbHome xfs 4.0G 45M 4.0G 2% /home /dev/mapper/VGExaDb-LVDbVar1 xfs 2.0G 90M 2.0G 5% /var /dev/mapper/VGExaDb-LVDbVarLog xfs 18G 135M 18G 1% /var/log /dev/mapper/VGExaDb-LVDbVarLogAudit xfs 1014M 89M 926M 9% /var/log/audit /dev/mapper/VGExaDb-LVDbTmp xfs 3.0G 33M 3.0G 2% /tmp /dev/mapper/VGExaDb-LVDbKdump xfs 20G 33M 20G 1% /crashfiles /dev/mapper/VGExaDbDisk.u01.5.img-LVDBDisk xfs 5.0G 33M 5.0G 1% /u01 /dev/mapper/VGExaDbDisk.u02.10.img-LVDBDisk xfs 10G 33M 10G 1% /u02 /dev/mapper/VGExaDbDisk.u03.15.img-LVDBDisk xfs 15G 33M 15G 1% /u03 /dev/mapper/VGExaDbDisk.grid19.7.0.0.200414.img-LVDBDisk xfs 20G 6.0G 15G 30% /u01/app/19.0.0.0/gridFrom the above output, you could derive the following table of information to use later in the commands that create the logical volume snapshots and backup files.
File system VG Name LV Name Backup Label Short Label /dev/mapper/VGExaDb-LVDbSys1VGExaDbLVDbSys1rootroot_snap/dev/mapper/VGExaDb-LVDbHomeVGExaDbLVDbHomehomehome_snap/dev/mapper/VGExaDb-LVDbVar1VGExaDbLVDbVar1varvar_snap/dev/mapper/VGExaDb-LVDbVarLogVGExaDbLVDbVarLogvarlogvarlog_snap/dev/mapper/VGExaDb-LVDbVarLogAuditVGExaDbLVDbVarLogAuditvarlogauditaudit_snap/dev/mapper/VGExaDb-LVDbTmpVGExaDbLVDbTmptmptmp_snap/dev/mapper/VGExaDb-LVDbKdumpVGExaDbLVDbKdumpcrashfilescrash_snap/dev/mapper/VGExaDbDisk.u01.5.img-LVDBDiskVGExaDbDisk.u01.5.imgLVDBDisku01u01_snap/dev/mapper/VGExaDbDisk.u02.10.img-LVDBDiskVGExaDbDisk.u02.10.imgLVDBDisku02u02_snap/dev/mapper/VGExaDbDisk.u03.15.img-LVDBDiskVGExaDbDisk.u03.15.imgLVDBDisku03u03_snap/dev/mapper/VGExaDbDisk.grid19.7.0.0.200414.img-LVDBDiskVGExaDbDisk.grid19.7.0.0.200414.imgLVDBDisku01app19000gridgrid_snapNote:
-
The information gathered from your guest may be significantly different from this example. Ensure that you gather the required information directly from your guest and only use current information.
- Depending on the currently active system volume, the logical volume for the root
(
/) file system isLVDbSys1orLVDbSys2. Likewise, the logical volume for the/varfile system is eitherLVDbVar1orLVDbVar2.
-
- Create the file system snapshots and backup files.
Use the table of information for your guest, which you gathered in the previous step.
Perform the following for each row in your table, substituting the appropriate values in each command.
- Create the snapshot.
# lvcreate -L1G -s -n LV-Name_snap /dev/VG-Name/LV-Name - Label the snapshot.
# xfs_admin -L Short-Label /dev/VG-Name/LV-Name_snap - Mount the snapshot.
# mkdir -p /root/mnt/Backup-Label # mount -o nouuid /dev/VG-Name/LV-Name_snap /root/mnt/Backup-Label - Change to the directory for the backup.
# cd /root/mnt/Backup-Label - Create the backup file.
-
For the root (
/) file system only, use the following command to include the contents of/bootin the backup file:# tar --acls --xattrs --xattrs-include=* --format=pax -pjcvf /root/remote_FS/rootfs-boot.tar.bz2 * /boot > /tmp/backup_tar.stdout 2> /tmp/backup_tar.stderr -
Otherwise, use the following command template:
# tar --acls --xattrs --xattrs-include=* --format=pax -pjcvf /root/remote_FS/Backup-Label.tar.bz2 * > /tmp/backup_tar.stdout 2> /tmp/backup_tar.stderr
-
- Check the
/tmp/backup_tar.stderrfile for any significant errors.You can ignore errors about failing to archive open sockets, and other similar errors.
- Unmount and remove the snapshot.
# cd / # umount /root/mnt/Backup-Label # /bin/rmdir /root/mnt/Backup-Label # lvremove -f /dev/VG-Name/LV-Name_snap
- Create the snapshot.
- Unmount the NFS share.
# umount /root/remote_FS - Re-create the
/dev/VGExaDb/LVDoNotRemoveOrUselogical volume.-
On guests using Oracle Exadata System Software release 25.2 or later, create the
/dev/VGExaDb/LVDoNotRemoveOrUselogical volume to occupy all the available free space in theVGExaDbvolume group:# lvm lvcreate -n LVDoNotRemoveOrUse -l 100%FREE VGExaDb -y -
On guests using a system software release prior to Oracle Exadata System Software release 25.2, create the
/dev/VGExaDb/LVDoNotRemoveOrUselogical volume to occupy 2 GB of space in theVGExaDbvolume group:# lvm lvcreate -n LVDoNotRemoveOrUse -L2G VGExaDb -y
-
Parent topic: Backing up the Oracle Linux KVM Guests