xfs文件系统完全备份、增量备份、差异备份的实验

整个实验我们会进行一次完全备份、两次增量备份、一次差异备份,来阐述其中的备份思想

1.创建一个文件写入hello ,并对其进行完全备份

[root@localhost mnt]# echo hello >>file
[root@localhost mnt]# xfsdump -L all -M dumpfile -l 0 - /mnt | xz > /xfs/xfs.$(date +%Y%m%d).all0.xz

查看我们存放备份的目录

[root@localhost mnt]# ls /xfs/
xfs.20190613.all0.xz

2.在创建一个文件写入world,并对其进行增量备份

[root@localhost mnt]# echo world >>file1 
[root@localhost mnt]# xfsdump -L all -M dumpfile -l 1 - /mnt | xz > /xfs/xfs.$(date +%Y%m%d).all1.xz

查看我们存放备份的目录

[root@localhost mnt]# ls /xfs/
xfs.20190613.all0.xz  xfs.20190613.all1.xz

3.在创建一个文件写入byebye,并对其进行增量备份

[root@localhost mnt]# echo byebye >>file2
[root@localhost mnt]# xfsdump -L all -M dumpfile -l 2 - /mnt | xz > /xfs/xfs.$(date +%Y%m%d).all2.xz

4.再做一次差异备份

[root@localhost mnt]# xfsdump -L all -M dumpfile -l 1 - /mnt | xz > /xfs/xfs.$(date +%Y%m%d).cha1.xz

查看我们存放备份的目录

[root@localhost mnt]# ls /xfs/
xfs.20190613.all0.xz  xfs.20190613.all1.xz  xfs.20190613.all2.xz  xfs.20190613.cha1.xz

准备工作完成,下面开始测试

删除当前目录的文件

[root@localhost mnt]# ls
file  file1  file2
[root@localhost mnt]# rm -rf *
[root@localhost mnt]# ls
[root@localhost mnt]# 

1.我们首先恢复完全备份,并查看

[root@localhost mnt]# xzcat /xfs/xfs.20190613.all0.xz | xfsrestore - /mnt/
[root@localhost mnt]# cat file 
hello

我们可以看到我们的完全备份的内容已经恢复了

2.恢复第一次的增量备份,并查看

[root@localhost mnt]# xzcat /xfs/xfs.20190613.all1.xz | xfsrestore - /mnt/
[root@localhost mnt]# ls 
file  file1
[root@localhost mnt]# cat file1 
world

我们可以看到第一次增量备份的文件和内容已经恢复

3.恢复第二次的增量备份,并查看

[root@localhost mnt]# xzcat /xfs/xfs.20190613.all2.xz | xfsrestore - /mnt/
[root@localhost mnt]# ls
file  file1  file2
[root@localhost mnt]# cat file2 
byebye

4.进行差异备测试

我们先删除增量备份恢复的数据,先进行完全备份

[root@localhost mnt]# xzcat /xfs/xfs.20190613.all0.xz | xfsrestore - /mnt/

 [root@localhost mnt]# ls
  file

  [root@localhost mnt]# cat file 

 hello

进行差异备份恢复

[root@localhost mnt]# xzcat /xfs/xfs.20190613.cha1.xz | xfsrestore - /mnt/
[root@localhost mnt]# ls
file  file1  file2
[root@localhost mnt]# cat file1 file2 
world
byebye

我们可以看到通过差异备份恢复完全备份之前的所有数据

原文地址:https://www.cnblogs.com/loganSxb/p/11016988.html