CENTOS7 uses the XFS format as the default file system,
XFS provides xfsdump backup, Xfsrestore recovery
- XFS's backup and recovery process can be interrupted and then resumed without freezing the file, without freezing the file system
- Xfsdump even provides high-performance multi-threaded backup operations----He splits a dump into multiple streams, each of which can be sent to a different destination
There are two backup levels for the Xfsdump, the default is 0
- Level 0 Representative: Full backup
- 1 to 9 Level rep: Incremental Backup
- Full backup : Complete replication of the specified backup directory every time, regardless of whether the file under the directory has changed
- Incremental backup : A file backup that changes after the backup (first, second, until previous)
- differential backup : Each time the first full backup relies on a changed file for backup
CENTOS7, add a virtual hard disk, (prepare a test environment)
Normal use of a hard disk process
- Add disk > Partition > Format > Mount
1 Adding disks
turn CentOS off by virtual machine > HDD > Add Device > new hard drive, boot CentOS
2 Partitioning
ls/dev/sd* can see one more /dev/sdb, this is the second disk (just added)
/dev/sdb
Input P view partition n new partition select P Primary partition W Save
3 formatting
/dev/sdb1
4 Mounting
//dev/sdb1/sdb1/
Back up the entire system
Xfsdump-f Backup storage location to back up the path or directory
- Note: The path of the backup cannot be written as/sdb1/
- Can be written as/DEV/SDB1 or/SDB1.
Xfsdump-f/opt/dump_sdb1/dev/
You can also specify that the backup is free of interaction and facilitate late scheduled backups
Xfsdump-f/opt/dump_sdb1/dev/sdb1-l dump_sdb1-m SDB1
- -l Specifies the session label, which records each backed up session header, which is a simple description of the filesystem
- -m specify device label, record storage media header, here to fill out the simple description of this media
Of course, you can also back up a directory in a partition
Parameter:-S
- -S file path to backup only the specified files
- -s specifies that the path is written relative to the path
Xfsdump-f/opt/dump_grub2-s grub2/grub.cfg/boot-l dump_grup2-m Boot
- The grub2/grub.cfg specified after-s in this command is located under the boot directory
File System Recovery
Xfsrestore--f/opt/dump_sdb1/sdb1
- Recovering individual files
Xfsrestore-f/opt/dump_grub2-s Grub2/grub.cfg/boot
The following restrictions apply when using Xfsdump
Xfsdump does not support a file backup command that is not mounted xfsdump must have root permission to operate Xfsdump can only back up the data of the XFS file system Xfsdump Backup, only let Xfsrestore parse
Incremental backup
Concept: Refers to the last full backup or after the last incremental backup, each subsequent backup only need to back up with the previous increase or deletion of files compared to the first incremental backup of the object is the full backup after the resulting increase and modification of the file, Incremental and modified files resulting from the first incremental backup when the object is being incrementally backed up for the second time
- Advantage: There is no duplicate backup data, so the amount of data backed up is small and the time required for backup is relatively short
- Cons: Data recovery is relatively cumbersome, and he needs the last full backup and all incremental backups to be fully successful, and they must be reversed back-by-side from full backup to time in this incremental backup, thus potentially prolonging recovery time
Actual combat:
1 full backup for the first time
-f/opt/dump_sdb1/dev/sdb1-l dump_sdb1-m SDB1
2 Add content to the directory you want to back up and make incremental backups
1 -f/opt/dump_sdb1. 1 /dev/sdb1-l dump_sdb1. 1 -M SDB1
-L <level> : do a backup of level 1
3 Add content and proceed with incremental backup
2 -f/opt/dump_sdb1. 2 /dev/sdb1-l dump_sdb1. 2 -M sdb1
-L <level> do a backup of level 2
4 Delete raw data,
RM-RF/SDB1/*
Now, how do we recover?
Steps:
- Restore a full backup first
-
- Situation one: Restore the last incremental backup, (if the two incremental backups are 1 levels, you only need to back up the last increment)
- Situation Two: If you do is 1 times the first time, the second is 2 times, then you need to restore the time to recover 1 times, then 2 times, and so on
- So obviously, our example is the situation two
-F/OPT/DUMP_SDB1/-f/opt/dump_sdb1. 1 /-f/opt/dump_sdb1. 2 /SDB1
Tests have found that the order of the first and second incremental restores can be reversed because they are backing up specific data
Linux XFS File System