Linux dump命令

dump - ext2/3 filesystem backup 在使用dump进行备份的时候,可以使用不同的备份等级(level), 当使用level 0进行备份的时候,就是最初的完整备份,然后可以再使用level 1对在进行了level 0备份后的基础上,对有改动的地方进行备份,依次类推level 2......。dump不仅可以针对整个文件系统进行备份,也可以针对单一目录进行备份,但是在对单一目录进行备份的时候,就不支持使用备份等级,就只能使用最初的完整备份(level 0)

命令格式dump [-Suvj] [-level] [-f 备份档] 待备份资料 更多详细信息,可以参考man dump页面,友情链接:Linux restore命令

参数说明

  • -S:仅列出后面的待备份数据需要多少磁盘空间才能够备份完毕
  • -u:将这次dump的时间记录到/etc/dumpdates文件中
  • -v:显示dump的备份过程
  • -j:加入bzip2的支持!将数据进行压缩,默认bzip2压缩等级为2,如果不用-j参数,dump默认是不会使用压缩功能
  • -level:备份等级,从-0~-9共十个等级,对单一目录进行备份,就只能用-0参数进行备份
  • -f:有点类似tar命令,后面接产生的档案,也可以接例如/dev/st0装置文件名
  • -W:列出在/etc/fstab里面的具有dump设定的partition是否有备份过

针对整个文件系统进行备份

[root@rhel6164 ~]# dump -u0j -f /tmp/boot.bakup /boot
  DUMP: Date of this level 0 dump: Thu Dec 25 09:21:28 2014
  DUMP: Dumping /dev/vda1 (/boot) to /tmp/boot.bakup
  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 21510 blocks.
  DUMP: Volume 1 started with block 1 at: Thu Dec 25 09:21:28 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /tmp/boot.bakup
  DUMP: Volume 1 completed at: Thu Dec 25 09:21:35 2014
  DUMP: Volume 1 took 0:00:07
  DUMP: Volume 1 transfer rate: 2761 kB/s
  DUMP: Volume 1 21590kB uncompressed, 19328kB compressed, 1.118:1
  DUMP: 21590 blocks (21.08MB) on 1 volume(s)
  DUMP: finished in 7 seconds, throughput 3084 kBytes/sec
  DUMP: Date of this level 0 dump: Thu Dec 25 09:21:28 2014
  DUMP: Date this dump completed:  Thu Dec 25 09:21:35 2014
  DUMP: Average transfer rate: 2761 kB/s
  DUMP: Wrote 21590kB uncompressed, 19328kB compressed, 1.118:1
  DUMP: DUMP IS DONE
[root@rhel6164 ~]# cat /etc/dumpdates #备份信息
/dev/vda1 0 Thu Dec 25 09:21:28 2014 +0800
[root@rhel6164 ~]# touch /boot/testing #修改/boot内容
[root@rhel6164 ~]# dump -u1j -f /tmp/boot.bakup1 /boot #重新备份
  DUMP: Date of this level 1 dump: Thu Dec 25 09:24:08 2014
  DUMP: Date of last level 0 dump: Thu Dec 25 09:21:28 2014
  DUMP: Dumping /dev/vda1 (/boot) to /tmp/boot.bakup1
  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 47 blocks.
  DUMP: Volume 1 started with block 1 at: Thu Dec 25 09:24:08 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /tmp/boot.bakup1
  DUMP: Volume 1 completed at: Thu Dec 25 09:24:08 2014
  DUMP: 50 blocks (0.05MB) on 1 volume(s)
  DUMP: finished in less than a second
  DUMP: Date of this level 1 dump: Thu Dec 25 09:24:08 2014
  DUMP: Date this dump completed:  Thu Dec 25 09:24:08 2014
  DUMP: Average transfer rate: 0 kB/s
  DUMP: Wrote 50kB uncompressed, 11kB compressed, 4.546:1
  DUMP: DUMP IS DONE
[root@rhel6164 ~]# cat /etc/dumpdates #备份信息
/dev/vda1 0 Thu Dec 25 09:21:28 2014 +0800
/dev/vda1 1 Thu Dec 25 09:24:08 2014 +0800
[root@rhel6164 ~]# ll /tmp/* | grep boot #备份文件
-rw-r--r-- 1 root    root    19792161 Dec 25 09:21 boot.bakup
-rw-r--r-- 1 root    root       11299 Dec 25 09:24 boot.bakup1


针对单一目录进行备份

[root@rhel6164 ~]# dump -0j -f /tmp/etc.bakup /etc #这里只能用-0参数进行最初的完整备份
  DUMP: Date of this level 0 dump: Thu Dec 25 09:33:36 2014
  DUMP: Dumping /dev/mapper/vg_rhel6164-lv_root (/ (dir etc)) to /tmp/etc.bakup
  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 38493 blocks.
  DUMP: Volume 1 started with block 1 at: Thu Dec 25 09:33:37 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /tmp/etc.bakup
  DUMP: Volume 1 completed at: Thu Dec 25 09:33:46 2014
  DUMP: Volume 1 took 0:00:09
  DUMP: Volume 1 transfer rate: 1196 kB/s
  DUMP: Volume 1 43970kB uncompressed, 10765kB compressed, 4.085:1
  DUMP: 43970 blocks (42.94MB) on 1 volume(s)
  DUMP: finished in 9 seconds, throughput 4885 kBytes/sec
  DUMP: Date of this level 0 dump: Thu Dec 25 09:33:36 2014
  DUMP: Date this dump completed:  Thu Dec 25 09:33:46 2014
  DUMP: Average transfer rate: 1196 kB/s
  DUMP: Wrote 43970kB uncompressed, 10765kB compressed, 4.085:1
  DUMP: DUMP IS DONE

### Linux Dump 命令的用法 `dump` 是一种用于备份文件系统的工具,在 Linux 和类 Unix 系统中广泛使用。它主要用于将整个文件系统或部分数据写入到磁带或其他存储介质上,以便进行长期保存或灾难恢复。 以下是 `dump` 的基本语法以及一些常见的选项: #### 基本语法 ```bash dump [-0123456789acfknquvW] [-d density] [-s feet] [-B blocks] [-b blocksize] [-C cachesize] [-D file] [-F script] [-h level] [-j compression_level] [-L label] [-Q file] [-T date] [-z compression_level] files-to-dump ``` #### 主要参数说明 - `-0`: 表示完全备份 (level 0 backup),这是默认级别。 - `-1` 到 `-9`: 表示增量备份的不同级别,其中较高的数字表示更高级别的增量备份[^5]。 - `-f destination`: 指定目标设备或文件名,可以是一个本地磁盘路径或者远程主机上的位置。 - `-u`: 更新 `/etc/dumpdates` 文件中的记录条目,该文件跟踪每次执行 dump 后的状态信息。 - `-w`: 显示哪些文件系统需要被转储而无需实际运行任何操作。 - `-W`: 类似于 `-w` 参数的功能,但它会提供更加详细的输出描述。 #### 示例用法 ##### 完全备份根目录至外部驱动器 假设您希望创建一个完整的根分区 (`/`) 备份并将其存放到 USB 驱动器 `/mnt/usb_drive` 中,则可按如下方式调用命令: ```bash sudo dump -0uf /mnt/usb_drive/root_backup.dump / ``` 此命令将会把根目录的内容复制下来形成名为 `root_backup.dump` 的镜像文件,并放置在外接硬盘指定的位置里[^6]. ##### 使用压缩功能减少占用空间 如果想进一步降低所生成的数据量大小的话,还可以加入 gzip 或者 bzip2 来实现在线压缩过程: ```bash sudo dump -0ujbf 20 /mnt/usb_drive/compressed_root_backup.dump.bz2 / ``` 这里我们设置了压缩等级为20(范围是从1最低质量最快速度直到9最高质量和最慢的速度), 并且采用了bzip2算法来进行处理. #### 解决常见问题 当尝试利用 `dump` 进行工作时可能会遇到某些错误提示或者是行为不符合预期的情况发生. 下面列举了一些可能碰到的情形及其对应的解决方案: 1. **权限不足**: 如果收到类似于 "Permission denied" 错误消息, 可能是因为当前用户缺少必要的访问权利去读取源目录或是写入目的地址. 此种情况下应该切换成超级管理员身份再重试. 2. **找不到合适的媒体**: 当指定了不正确的设备名称作为目标媒介的时候也会引发异常状况. 应仔细核对输入的目标路径是否正确无误. 3. **内存溢出**: 对特别庞大的文件夹做备份有可能消耗掉大量的 RAM 资源从而导致程序崩溃退出. 尝试着分批次逐步完成这项任务或许能够缓解这个问题带来的影响. --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值