版权声明:欢迎转载与交流。https://blog.csdn.net/one2more/article/details/89930488
CentOS 7开始使用全新的xfs文件系统。XFS提供了xfsdump和xfsrestore工具协助备份和恢复XFS文件系统中的数据。xfsdump是按inode顺序备份一个XFS文件系统的。
CentOS 7选择xfs格式作为其默认文件系统,而且不再使用以前的ext文件系统,但是仍支持ext4文件系统。xfs应大数据而生,每单个文件系统最大可支持8EB;单个文件最大可支持16TB,不仅数据量大,而且扩展性高。还可以通过xfsdump和xfsrestore来备份和恢复(原始备份一般采用cp/rsync等)。
与传统的UNIX文件系统不同,XFS不需要在备份前卸载。对使用中的XFS文件系统就可以做备份并且能够保证镜像的一致性。XFS的备份和恢复过程是可以被中断然后再继续的,无需冻结文件系统。xfsdump甚至提供了高性能的多线路备份操作——它把一次dump拆分成多个数据流,每个数据流可被发往不同的目的地。
xfsdump的备份级别有以下两种,默认为0(即完全备份):
0 级别代表:完全备份
1~9 级别代表:增量备份
使用xfsdump时的一些限制:
1、xfsdump不支持没有挂载的文件系统(即只能针对挂载了的文件系统作备份);
2、xfsdump必须使用root权限才能进行操作(涉及整个文件系统,相对比较底层);
3、xfsdump只能备份XFS文件系统;
4、xfsdump备份的数据(档案或存储媒体)只能由xfsrestore来解析;
5、xfsdump是通过文件系统的UUID进行各备份文件档案之间的区分的,因此不能备份两个具有相同UUID的文件系统。
拓展:
完全备份:每次把指定的备份目录完整的复制一遍,不管目录下的文件有没有变化。
增量备份:每次将之前(第1次、第2次,一直到之前一次)做过备份之后有变化的文件进行备份。
差异备份:每次都将第一次完整备份以来有变化的文件进行备份。
正常添加一块磁盘的大致过程
:添加磁盘>>分区>>格式化>>挂载使用
(1)对磁盘进行分区(添加磁盘不多讲)
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xc8ebc274 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p # `p` 表示显示当前已有分区
磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xc8ebc274
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n # `n` 表示新增一个分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p # `p` 表示分区类型为主分区
分区号 (1-4,默认 1):1 # `1` 表示指定分区号为1
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):+1G # `+1G` 表示分区大小分配为1个G
分区 1 已设置为 Linux 类型,大小设为 1 GiB
命令(输入 m 获取帮助):p # `p` 表示显示当前已有分区
磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xc8ebc274
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 2099199 1048576 83 Linux
命令(输入 m 获取帮助):w # `w` 表示保存当前设置并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
(2)使用fdisk
格式化分区
[root@localhost ~]# mkfs -t xfs /dev/sdb1 # `-t`参数指定文件系统类型
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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
(3)创建挂载点,并挂载使用
[root@localhost ~]# mkdir /sdb1
[root@localhost ~]# mount /dev/sdb1 /sdb1
[root@localhost ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 11G 1.3G 9.5G 12% /
devtmpfs devtmpfs 501M 0 501M 0% /dev
tmpfs tmpfs 512M 0 512M 0% /dev/shm
tmpfs tmpfs 512M 7.0M 505M 2% /run
tmpfs tmpfs 512M 0 512M 0% /sys/fs/cgroup
/dev/sda1 xfs 312M 115M 197M 37% /boot
tmpfs tmpfs 103M 0 103M 0% /run/user/0
/dev/sdb1 xfs 1.1G 34M 1.1G 4% /sdb1
[root@localhost ~]# cd /sdb1
[root@localhost sdb1]# mkdir test
[root@localhost sdb1]# touch ./test/a
[root@localhost sdb1]# cp /etc/passwd ./
[root@localhost sdb1]# tree ./
./
├── passwd
└── test
└── a
1 directory, 2 files
xfsdump
备份整个分区(完全备份) 这种备份优点类似虚拟机的快照,当服务器被黑或遭到破坏后可以进行快速回复,做到有备无患
。
命令格式:xfsdump -f [备份存放的位置] [要备份的分区路径]
注意
:要备份的设备或路径不能写成/sdb1/
而是要写为/sdb1
一定切记不要写后面的/
(1)命令行交互式
进行备份
[root@localhost sdb1]# xfsdump -f /mnt/dump_sdb1 /sdb1
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
============================= dump label dialog ==============================
please enter label for this dump session (timeout in 300 sec)
-> dump_sdb1 # 指定一个备份会话标签
session label entered: "dump_sdb1"
--------------------------------- end dialog ---------------------------------
xfsdump: level 0 dump of localhost.localdomain:/sdb1
xfsdump: dump date: Tue May 7 22:00:32 2019
xfsdump: session id: f724bd78-76a8-4035-b0c6-a63002052ec9
xfsdump: session label: "dump_sdb1"
xfsdump: ino map phase 1: constructing initial dump list
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: 25856 bytes
xfsdump: /var/lib/xfsdump/inventory created
============================= media label dialog =============================
please enter label for media in drive 0 (timeout in 300 sec)
-> sdb1 # 制定一个设备标签
media label entered: "sdb1"
--------------------------------- 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 24528 bytes
xfsdump: dump size (non-dir files) : 1568 bytes
xfsdump: dump complete: 96 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dump_sdb1 OK (success)
xfsdump: Dump Status: SUCCESS
(2)指定备份时免交互操作
,方便利用脚本实现定时备份
[root@localhost sdb1]# xfsdump -f /mnt/dump_sdb1_full /sdb1 -L dump_sdb1_full -M sdb1full
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: level 0 dump of localhost.localdomain:/sdb1
xfsdump: dump date: Tue May 7 22:13:20 2019
xfsdump: session id: eec52a10-c5ea-40f6-b70e-a6279b6d52dd
xfsdump: session label: "dump_sdb1_full"
xfsdump: ino map phase 1: constructing initial dump list
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: 25856 bytes
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 24528 bytes
xfsdump: dump size (non-dir files) : 1568 bytes
xfsdump: dump complete: 0 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dump_sdb1_full OK (success)
xfsdump: Dump Status: SUCCESS
说明:
-L:表示指定xfsdump每次备份时记录的session标头,此处可已填写有针对性的易于分辨的说明性文字或描述。
-M:表示指定xfsdump每次备份时记录的存储媒体media的标头,此处可以填写此媒体的简要说明。
(3)针对单个文件进行备份(对/boot/grub2/grub.cfg
进行备份)
命令格式:
xfsdump -f [备份存放的位置] -s [要备份的文件或目录的相对路径] [要备份的分区路径]
-s 文件路径, 只对指定的文件进行备份,-s指定时,路径写的是相对路径(-s可以是目录或文件)
[root@localhost sdb1]# ll /boot/grub2/grub.cfg
-rw-r--r--. 1 root root 4253 5月 1 10:24 /boot/grub2/grub.cfg
[root@localhost sdb1]# xfsdump -f /mnt/dump_grub2 -s grub2/grub.cfg /boot -L dump_grub2 -M boot-sda1
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: level 0 dump of localhost.localdomain:/boot
xfsdump: dump date: Tue May 7 22:43:55 2019
xfsdump: session id: 6eafe4d7-e1c6-4543-bf4c-47ba27bc228c
xfsdump: session label: "dump_grub2"
xfsdump: ino map phase 1: constructing initial dump list
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: 29632 bytes
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 27976 bytes
xfsdump: dump size (non-dir files) : 4640 bytes
xfsdump: dump complete: 2 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dump_grub2 OK (success)
xfsdump: Dump Status: SUCCESS
备份成功后,我们可以在/var/lib/xfsdump/inventory
目录下看到生成的档案信息
[root@localhost sdb1]# ll /var/lib/xfsdump/inventory
总用量 28
-rw-r--r--. 1 root root 5080 5月 7 22:43 02ba02cd-5327-4381-8f1e-495b96e392e0.StObj
-rw-r--r--. 1 root root 312 5月 7 22:43 15e9e75d-0651-40ca-8b02-0cbc7531e512.InvIndex
-rw-r--r--. 1 root root 5760 5月 7 22:13 a744a250-cd58-4beb-9a5c-946b0ec59f48.StObj
-rw-r--r--. 1 root root 312 5月 7 22:13 e39b0d8b-30fb-4624-ac65-174e5a5061b5.InvIndex
-rw-r--r--. 1 root root 1120 5月 7 22:43 fstab
通过xfsdump -I
(大写
的i
) 来查看备份信息
[root@localhost sdb1]# xfsdump -I
(1)先删除文件
[root@localhost sdb1]# tree ./
./
├── passwd
└── test
└── a
[root@localhost sdb1]# rm -rf ./*
[root@localhost sdb1]# tree ./
./
0 directories, 0 files
(2)xfsrestore文件恢复
语法:xfsrestore -f [指定要恢复的文件等的备份位置] [指定存放恢复后的文件的路径]
1、恢复分区
[root@localhost sdb1]# xfsrestore -f /mnt/dump_sdb1 /sdb1
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /sdb1
xfsrestore: volume: /dev/sdb1
xfsrestore: session time: Tue May 7 22:00:32 2019
xfsrestore: level: 0
xfsrestore: session label: "dump_sdb1"
xfsrestore: media label: "sdb1"
xfsrestore: file system id: e39b0d8b-30fb-4624-ac65-174e5a5061b5
xfsrestore: session id: f724bd78-76a8-4035-b0c6-a63002052ec9
xfsrestore: media id: 5150a978-14f8-46fd-a5aa-a1a34afe19d1
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 3 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dump_sdb1 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost sdb1]# tree ./
./
├── passwd
└── test
└── a
1 directory, 2 files
1、恢复目录及目录下内容
[root@localhost sdb1]# mkdir /mnt/test1
[root@localhost sdb1]# xfsrestore -f /mnt/dump_grub2 -s grub2/grub.cfg /mnt/test1/
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /boot
xfsrestore: volume: /dev/sda1
xfsrestore: session time: Tue May 7 22:43:55 2019
xfsrestore: level: 0
xfsrestore: session label: "dump_grub2"
xfsrestore: media label: "boot-sda1"
xfsrestore: file system id: 15e9e75d-0651-40ca-8b02-0cbc7531e512
xfsrestore: session id: 6eafe4d7-e1c6-4543-bf4c-47ba27bc228c
xfsrestore: media id: 352f050b-cfb7-4f78-b286-93ac92c8c000
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 18 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 1 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dump_grub2 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost sdb1]# tree /mnt/test1/
/mnt/test1/
└── grub2
└── grub.cfg
1 directory, 1 file
或者
[root@localhost sdb1]# mkdir /mnt/test2
[root@localhost sdb1]# xfsrestore -f /mnt/dump_grub2 -s grub2 /mnt/test2
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /boot
xfsrestore: volume: /dev/sda1
xfsrestore: session time: Tue May 7 22:43:55 2019
xfsrestore: level: 0
xfsrestore: session label: "dump_grub2"
xfsrestore: media label: "boot-sda1"
xfsrestore: file system id: 15e9e75d-0651-40ca-8b02-0cbc7531e512
xfsrestore: session id: 6eafe4d7-e1c6-4543-bf4c-47ba27bc228c
xfsrestore: media id: 352f050b-cfb7-4f78-b286-93ac92c8c000
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 18 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 2 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dump_grub2 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost sdb1]# tree /mnt/test2
/mnt/test2
└── grub2
└── grub.cfg
1 directory, 1 file
增量备份指在第一次完全备份或之前一次增量备份后进行的备份,以后每次增量备份只需备份与前一次相比增加的或者被修改过的文件。
即,第一次增量备份的对象是进行完全备份后新产生的和修改过的文件;第二次增量备份的对象是进行第一次增量备份后新产生的和修改过的文件;依次类推。
(1)优缺点:
优点:避免了重复的备份数据,备份的数据量相对更小,备份所消耗的时间更短。
缺点:数据恢复相对比较麻烦,它需要通过上一次完全备份和所有增量备份的内容才能够完全恢复成功,并且它们必须依照从完全备份到依次增量备份的时间顺序依次反向恢复,因此恢复起来可能更耗时间。
(2)实战演练:增量备份
1、恢复实验环境
[root@localhost sdb1]# rm -rf /mnt/dump*
[root@localhost sdb1]# rm -rf /mnt/test*
[root@localhost sdb1]# ll /mnt
总用量 0
[root@localhost sdb1]# tree ./
./
├── passwd
└── test
└── a
1 directory, 2 files
2、进行第一次完全备份
[root@localhost sdb1]# xfsdump -f /mnt/dumpfull_sdb1 /sdb1 -L dumpfull-sdb1-first -M fenqusb1
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: level 0 dump of localhost.localdomain:/sdb1
xfsdump: dump date: Wed May 8 11:44:23 2019
xfsdump: session id: 793bfc1d-7a1c-4fb5-8d70-1a34237443f9
xfsdump: session label: "dumpfull-sdb1-first"
xfsdump: ino map phase 1: constructing initial dump list
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: 25856 bytes
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 24528 bytes
xfsdump: dump size (non-dir files) : 1568 bytes
xfsdump: dump complete: 2 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dumpfull_sdb1 OK (success)
xfsdump: Dump Status: SUCCESS
3、创建一些新内容,进行第一次(第1级别)增量备份
xfsdump -l [要进行备份的级别] -f [备份存放的位置] -s [要备份的文件或目录的相对路径] [要备份的分区路径]
[root@localhost sdb1]# touch /sdb1/1.txt /sdb1/2.txt
[root@localhost sdb1]# tree ./
./
├── 1.txt
├── 2.txt
├── passwd
└── test
└── a
1 directory, 4 files
[root@localhost sdb1]# xfsdump -l 1 -f /mnt/dump-add1-sdb1 /sdb1 -L dump-add1-sdb1 -M fenqusdb1-add1
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: level 1 incremental dump of localhost.localdomain:/sdb1 based on level 0 dump begun Wed May 8 11:44:23 2019
xfsdump: dump date: Wed May 8 11:52:24 2019
xfsdump: session id: 5b04d851-99af-4dc7-a773-5cdcdcf6428b
xfsdump: session label: "dump-add1-sdb1"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: pruning unneeded subtrees
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 21440 bytes
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 22368 bytes
xfsdump: dump size (non-dir files) : 0 bytes
xfsdump: dump complete: 0 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dump-add1-sdb1 OK (success)
xfsdump: Dump Status: SUCCESS
4、再创建一些新内容,进行第二次(第2级别)增量备份
[root@localhost sdb1]# touch /sdb1/test/a.txt /sdb1/test/b.txt
[root@localhost sdb1]# tree ./
./
├── 1.txt
├── 2.txt
├── passwd
└── test
├── a
├── a.txt
└── b.txt
1 directory, 6 files
[root@localhost sdb1]# xfsdump -l 2 -f /mnt/dump-add2-sdb1 /sdb1 -L dump-add2-sdb1 -M fenqusdb1-add2
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: level 2 incremental dump of localhost.localdomain:/sdb1 based on level 1 dump begun Wed May 8 11:52:24 2019
xfsdump: dump date: Wed May 8 12:03:08 2019
xfsdump: session id: 6f82c941-86c0-41d4-9bf8-e748c610909d
xfsdump: session label: "dump-add2-sdb1"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: pruning unneeded subtrees
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 21760 bytes
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 23056 bytes
xfsdump: dump size (non-dir files) : 0 bytes
xfsdump: dump complete: 0 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /mnt/dump-add2-sdb1 OK (success)
xfsdump: Dump Status: SUCCESS
5、删除所有内容后,根据时间顺序先恢复第一次(第0级别)完全备份
[root@localhost sdb1]# rm -rf /sdb1/ * #删除分区下所有内容
[root@localhost sdb1]# tree ./ #查看下分区下目录结构(有哪些内容)
./
0 directories, 0 files
[root@localhost sdb1]# ll /mnt #查看一下备份的名称
总用量 72
-rw-r--r--. 1 root root 22368 5月 8 11:52 dump-add1-sdb1
-rw-r--r--. 1 root root 23056 5月 8 12:03 dump-add2-sdb1
-rw-r--r--. 1 root root 24528 5月 8 11:44 dumpfull_sdb1
[root@localhost sdb1]# xfsrestore -f /mnt/dumpfull_sdb1 /sdb1 #恢复第一次(第0级别)完整备份
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /sdb1
xfsrestore: volume: /dev/sdb1
xfsrestore: session time: Wed May 8 11:44:23 2019
xfsrestore: level: 0
xfsrestore: session label: "dumpfull-sdb1-first"
xfsrestore: media label: "fenqusb1"
xfsrestore: file system id: e39b0d8b-30fb-4624-ac65-174e5a5061b5
xfsrestore: session id: 793bfc1d-7a1c-4fb5-8d70-1a34237443f9
xfsrestore: media id: 77a31fa4-9579-4c15-ae05-ab25947e97a7
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 3 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dumpfull_sdb1 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost sdb1]# tree ./ #查看到已经正确恢复啦
./
├── passwd
└── test
└── a
1 directory, 2 files
6、再恢复第一次(第1级别)增量备份
[root@localhost sdb1]# xfsrestore -f /mnt/dump-add1-sdb1 /sdb1 #恢复第一次(第1级别)增量备份
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /sdb1
xfsrestore: volume: /dev/sdb1
xfsrestore: session time: Wed May 8 11:52:24 2019
xfsrestore: level: 1
xfsrestore: session label: "dump-add1-sdb1"
xfsrestore: media label: "fenqusdb1-add1"
xfsrestore: file system id: e39b0d8b-30fb-4624-ac65-174e5a5061b5
xfsrestore: session id: 5b04d851-99af-4dc7-a773-5cdcdcf6428b
xfsrestore: media id: 4e1537b5-3a2e-4e9b-9504-088ce32634af
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 1 directories and 4 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 2 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dump-add1-sdb1 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost sdb1]# tree ./ #查看到已经正确恢复啦
./
├── 1.txt
├── 2.txt
├── passwd
└── test
└── a
1 directory, 4 files
7、最后恢复第二次(第2级别)增量备份
[root@localhost sdb1]# xfsrestore -f /mnt/dump-add2-sdb1 /sdb1 #恢复第二次(第2级别)增量备份
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /sdb1
xfsrestore: volume: /dev/sdb1
xfsrestore: session time: Wed May 8 12:03:08 2019
xfsrestore: level: 2
xfsrestore: session label: "dump-add2-sdb1"
xfsrestore: media label: "fenqusdb1-add2"
xfsrestore: file system id: e39b0d8b-30fb-4624-ac65-174e5a5061b5
xfsrestore: session id: 6f82c941-86c0-41d4-9bf8-e748c610909d
xfsrestore: media id: 61113b9e-5ce4-46c1-a90d-a2a6537f8891
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 7 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /mnt/dump-add2-sdb1 OK (success)
xfsrestore: Restore Status: SUCCESS
8、查看是否恢复成功
[root@localhost sdb1]# tree ./ #查看到已经正确恢复啦
./
├── 1.txt
├── 2.txt
├── passwd
└── test
├── a
├── a.txt
└── b.txt
1 directory, 6 files
9、总结及注意事项
步骤:
1)、先恢复完全备份(注意有多次
完全备份的时候注意后续恢复的连贯,恢复最新一次
的完全备份)
2)、情景一
:恢复最后一次增量备份(如果有两次或者两次以上的都是1级别的增量备份时,只需恢复最后一个1级别增量备份就可以了)
3)、情景二
:如果第一次是1级别的增量备份,第二次是2级别的增量备份时,在恢复的过程中需要先恢复0级别
的完全备份,然后恢复1级别
的增量备份,最后再恢复2级别
的增量备份。
4)、其实实际的恢复过程中,是可以打乱备份的顺序,但是要想完全恢复所有数据,必须把所有的备份全部恢复一遍,否则一旦有遗漏的话数据恢复的是不完整的。非常!非常!非常!不建议打乱顺序去恢复数据