一、命令简介
Linux dump命令用于备份文件系统。dump为备份工具程序,可将目录或整个文件系统备份至指定的设备,或备份成一个大文件。dump命令只可以备份ext2/3/4格式的文件系统,centos7默认未安装dump命令,可以使用yum install -y dump
安装此命令。
二、使用示例
1、全量备份/boot分区
[root@bunian ~]# dump -0uj -f /root/boot.bak.bz2 /boot/DUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak.bz2DUMP: Label: noneDUMP: Writing 10 Kilobyte recordsDUMP: Compressing output at compression level 2 (bzlib)DUMP: mapping (Pass I) [regular files]DUMP: mapping (Pass II) [directories]DUMP: estimated 115437 blocks.DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:10:06 2021DUMP: dumping (Pass III) [directories]DUMP: dumping (Pass IV) [regular files]DUMP: Closing /root/boot.bak.bz2DUMP: Volume 1 completed at: Fri Jul 30 16:10:22 2021DUMP: Volume 1 took 0:00:16DUMP: Volume 1 transfer rate: 6656 kB/sDUMP: Volume 1 116040kB uncompressed, 106506kB compressed, 1.090:1DUMP: 116040 blocks (113.32MB) on 1 volume(s)DUMP: finished in 16 seconds, throughput 7252 kBytes/secDUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021DUMP: Date this dump completed: Fri Jul 30 16:10:22 2021DUMP: Average transfer rate: 6656 kB/sDUMP: Wrote 116040kB uncompressed, 106506kB compressed, 1.090:1DUMP: DUMP IS DONE[root@bunian ~]# ll -h /root/总用量 105M-rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg-rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2[root@bunian ~]# df -hT文件系统 类型 容量 已用 可用 已用% 挂载点/dev/mapper/centos-root ext4 9.8G 1.2G 8.1G 13% /devtmpfs devtmpfs 908M 0 908M 0% /devtmpfs tmpfs 919M 0 919M 0% /dev/shmtmpfs tmpfs 919M 8.5M 911M 1% /runtmpfs tmpfs 919M 0 919M 0% /sys/fs/cgroup/dev/sda1 ext4 976M 115M 795M 13% /boot/dev/mapper/centos-home ext4 17G 45M 16G 1% /hometmpfs tmpfs 184M 0 184M 0% /run/user/0[root@bunian ~]# dump -0uj -f /root/boot.bak.bz2 /boot/ DUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 115437 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:10:06 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.bak.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:10:22 2021 DUMP: Volume 1 took 0:00:16 DUMP: Volume 1 transfer rate: 6656 kB/s DUMP: Volume 1 116040kB uncompressed, 106506kB compressed, 1.090:1 DUMP: 116040 blocks (113.32MB) on 1 volume(s) DUMP: finished in 16 seconds, throughput 7252 kBytes/sec DUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021 DUMP: Date this dump completed: Fri Jul 30 16:10:22 2021 DUMP: Average transfer rate: 6656 kB/s DUMP: Wrote 116040kB uncompressed, 106506kB compressed, 1.090:1 DUMP: DUMP IS DONE [root@bunian ~]# ll -h /root/ 总用量 105M -rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg -rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2 [root@bunian ~]# df -hT 文件系统 类型 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root ext4 9.8G 1.2G 8.1G 13% / devtmpfs devtmpfs 908M 0 908M 0% /dev tmpfs tmpfs 919M 0 919M 0% /dev/shm tmpfs tmpfs 919M 8.5M 911M 1% /run tmpfs tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/sda1 ext4 976M 115M 795M 13% /boot /dev/mapper/centos-home ext4 17G 45M 16G 1% /home tmpfs tmpfs 184M 0 184M 0% /run/user/0[root@bunian ~]# dump -0uj -f /root/boot.bak.bz2 /boot/ DUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 115437 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:10:06 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.bak.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:10:22 2021 DUMP: Volume 1 took 0:00:16 DUMP: Volume 1 transfer rate: 6656 kB/s DUMP: Volume 1 116040kB uncompressed, 106506kB compressed, 1.090:1 DUMP: 116040 blocks (113.32MB) on 1 volume(s) DUMP: finished in 16 seconds, throughput 7252 kBytes/sec DUMP: Date of this level 0 dump: Fri Jul 30 16:10:06 2021 DUMP: Date this dump completed: Fri Jul 30 16:10:22 2021 DUMP: Average transfer rate: 6656 kB/s DUMP: Wrote 116040kB uncompressed, 106506kB compressed, 1.090:1 DUMP: DUMP IS DONE [root@bunian ~]# ll -h /root/ 总用量 105M -rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg -rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2 [root@bunian ~]# df -hT 文件系统 类型 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root ext4 9.8G 1.2G 8.1G 13% / devtmpfs devtmpfs 908M 0 908M 0% /dev tmpfs tmpfs 919M 0 919M 0% /dev/shm tmpfs tmpfs 919M 8.5M 911M 1% /run tmpfs tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/sda1 ext4 976M 115M 795M 13% /boot /dev/mapper/centos-home ext4 17G 45M 16G 1% /home tmpfs tmpfs 184M 0 184M 0% /run/user/0
2、增量备份/boot分区
在/boot分区创建一个测试文件hi.txt
[root@bunian ~]# cd /boot/[root@bunian boot]# touch hi.txt[root@bunian boot]# echo “this is a test” > hi.txt[root@bunian ~]# cd /boot/ [root@bunian boot]# touch hi.txt [root@bunian boot]# echo “this is a test” > hi.txt[root@bunian ~]# cd /boot/ [root@bunian boot]# touch hi.txt [root@bunian boot]# echo “this is a test” > hi.txt
然后增量备份/boot分区
[root@bunian ~]# dump -1uj -f /root/boot.bak1.bz2 /boot/DUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021DUMP: Date of last level 0 dump: Fri Jul 30 16:16:41 2021DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak1.bz2DUMP: Label: noneDUMP: Writing 10 Kilobyte recordsDUMP: Compressing output at compression level 2 (bzlib)DUMP: mapping (Pass I) [regular files]DUMP: mapping (Pass II) [directories]DUMP: estimated 39 blocks.DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:17:15 2021DUMP: dumping (Pass III) [directories]DUMP: dumping (Pass IV) [regular files]DUMP: Closing /root/boot.bak1.bz2DUMP: Volume 1 completed at: Fri Jul 30 16:17:15 2021DUMP: 40 blocks (0.04MB) on 1 volume(s)DUMP: finished in less than a secondDUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021DUMP: Date this dump completed: Fri Jul 30 16:17:15 2021DUMP: Average transfer rate: 0 kB/sDUMP: Wrote 40kB uncompressed, 11kB compressed, 3.637:1DUMP: DUMP IS DONE[root@bunian ~]# dump -1uj -f /root/boot.bak1.bz2 /boot/ DUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021 DUMP: Date of last level 0 dump: Fri Jul 30 16:16:41 2021 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak1.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 39 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:17:15 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.bak1.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:17:15 2021 DUMP: 40 blocks (0.04MB) on 1 volume(s) DUMP: finished in less than a second DUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021 DUMP: Date this dump completed: Fri Jul 30 16:17:15 2021 DUMP: Average transfer rate: 0 kB/s DUMP: Wrote 40kB uncompressed, 11kB compressed, 3.637:1 DUMP: DUMP IS DONE[root@bunian ~]# dump -1uj -f /root/boot.bak1.bz2 /boot/ DUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021 DUMP: Date of last level 0 dump: Fri Jul 30 16:16:41 2021 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak1.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 39 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:17:15 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.bak1.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:17:15 2021 DUMP: 40 blocks (0.04MB) on 1 volume(s) DUMP: finished in less than a second DUMP: Date of this level 1 dump: Fri Jul 30 16:17:15 2021 DUMP: Date this dump completed: Fri Jul 30 16:17:15 2021 DUMP: Average transfer rate: 0 kB/s DUMP: Wrote 40kB uncompressed, 11kB compressed, 3.637:1 DUMP: DUMP IS DONE
查看增量备份文件大小
[root@bunian ~]# ll -h /root总用量 105M-rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg-rw-r–r--. 1 root root 12K 7月 30 16:17 boot.bak1.bz2-rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2[root@bunian ~]# ll -h /root 总用量 105M -rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg -rw-r–r--. 1 root root 12K 7月 30 16:17 boot.bak1.bz2 -rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2[root@bunian ~]# ll -h /root 总用量 105M -rw-------. 1 root root 1.8K 7月 30 16:03 anaconda-ks.cfg -rw-r–r--. 1 root root 12K 7月 30 16:17 boot.bak1.bz2 -rw-r–r--. 1 root root 105M 7月 30 16:10 boot.bak.bz2
3、查询分区的最新备份记录
[root@bunian ~]# dump -WLast dump(s) done (Dump ‘>’ file systems):/dev/mapper/centos-root ( /) Last dump: never/dev/sda1 ( /boot) Last dump: Level 1, Date Fri Jul 30 16:17:15 2021/dev/mapper/centos-home ( /home) Last dump: never[root@bunian ~]# dump -W Last dump(s) done (Dump ‘>’ file systems): /dev/mapper/centos-root ( /) Last dump: never /dev/sda1 ( /boot) Last dump: Level 1, Date Fri Jul 30 16:17:15 2021 /dev/mapper/centos-home ( /home) Last dump: never[root@bunian ~]# dump -W Last dump(s) done (Dump ‘>’ file systems): /dev/mapper/centos-root ( /) Last dump: never /dev/sda1 ( /boot) Last dump: Level 1, Date Fri Jul 30 16:17:15 2021 /dev/mapper/centos-home ( /home) Last dump: never
4、备份文件或目录
备份文件和目录只能使用0级别,即只能全量备份。
[root@bunian ~]# dump -0j -f /home/etc.dump.bz2 /etc/DUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021DUMP: Dumping /dev/mapper/centos-root (/ (dir etc)) to /home/etc.dump.bz2DUMP: Label: noneDUMP: Writing 10 Kilobyte recordsDUMP: Compressing output at compression level 2 (bzlib)DUMP: mapping (Pass I) [regular files]DUMP: mapping (Pass II) [directories]DUMP: estimated 35010 blocks.DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:23:30 2021DUMP: dumping (Pass III) [directories]DUMP: dumping (Pass IV) [regular files]DUMP: Closing /home/etc.dump.bz2DUMP: Volume 1 completed at: Fri Jul 30 16:23:35 2021DUMP: Volume 1 took 0:00:05DUMP: Volume 1 transfer rate: 2470 kB/sDUMP: Volume 1 39190kB uncompressed, 12350kB compressed, 3.174:1DUMP: 39190 blocks (38.27MB) on 1 volume(s)DUMP: finished in 5 seconds, throughput 7838 kBytes/secDUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021DUMP: Date this dump completed: Fri Jul 30 16:23:35 2021DUMP: Average transfer rate: 2470 kB/sDUMP: Wrote 39190kB uncompressed, 12350kB compressed, 3.174:1DUMP: DUMP IS DONE[root@bunian ~]# dump -0j -f /home/etc.dump.bz2 /etc/ DUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021 DUMP: Dumping /dev/mapper/centos-root (/ (dir etc)) to /home/etc.dump.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 35010 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:23:30 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /home/etc.dump.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:23:35 2021 DUMP: Volume 1 took 0:00:05 DUMP: Volume 1 transfer rate: 2470 kB/s DUMP: Volume 1 39190kB uncompressed, 12350kB compressed, 3.174:1 DUMP: 39190 blocks (38.27MB) on 1 volume(s) DUMP: finished in 5 seconds, throughput 7838 kBytes/sec DUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021 DUMP: Date this dump completed: Fri Jul 30 16:23:35 2021 DUMP: Average transfer rate: 2470 kB/s DUMP: Wrote 39190kB uncompressed, 12350kB compressed, 3.174:1 DUMP: DUMP IS DONE[root@bunian ~]# dump -0j -f /home/etc.dump.bz2 /etc/ DUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021 DUMP: Dumping /dev/mapper/centos-root (/ (dir etc)) to /home/etc.dump.bz2 DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: Compressing output at compression level 2 (bzlib) DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 35010 blocks. DUMP: Volume 1 started with block 1 at: Fri Jul 30 16:23:30 2021 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /home/etc.dump.bz2 DUMP: Volume 1 completed at: Fri Jul 30 16:23:35 2021 DUMP: Volume 1 took 0:00:05 DUMP: Volume 1 transfer rate: 2470 kB/s DUMP: Volume 1 39190kB uncompressed, 12350kB compressed, 3.174:1 DUMP: 39190 blocks (38.27MB) on 1 volume(s) DUMP: finished in 5 seconds, throughput 7838 kBytes/sec DUMP: Date of this level 0 dump: Fri Jul 30 16:23:29 2021 DUMP: Date this dump completed: Fri Jul 30 16:23:35 2021 DUMP: Average transfer rate: 2470 kB/s DUMP: Wrote 39190kB uncompressed, 12350kB compressed, 3.174:1 DUMP: DUMP IS DONE
三、使用语法及参数说明
1、使用语法
#dump [参数]#dump [参数]#dump [参数]
2、参数说明
常用参数 | 参数说明 |
---|---|
-0123456789 | 备份的层级 |
-b | 指定区块的大小,单位为KB |
-B | 指定备份卷册的区块数目 |
-c | 修改备份磁带预设的密度与容量 |
-d | 设置磁带的密度。单位为BPI |
-f | 指定备份设备 |
-h | 当备份层级等于或大于指定的层级时,将不备份用户标示为”nodump”的文件 |
-j | 使用bzlib库压缩备份文件 |
-n | 当备份工作需要管理员介入时,向所有”operator”群组中的使用者发出通 |
-s | 备份磁带的长度,单位为英尺 |
-T | 指定开始备份的时间与日期 |
-u | 备份完毕后,在/etc/dumpdates中记录备份的文件系统,层级,日期与时间等 |
-w | 与-W类似,但仅显示需要备份的文件 |
-W | 显示需要备份的文件及其最后一次备份的层级,时间与日期 |
© 版权声明
本站文章由不念博客原创,未经允许严禁转载!
THE END