码迷,mamicode.com
首页 > 系统相关 > 详细

shell dd备份系统

时间:2017-05-10 17:58:56      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:shell dd备份系统

备份MBR、根分区、Boot分区

#!/bin/bash

Bak_dir=/mnt   #已挂载的移动硬盘或其他外设

Mbr=`fdisk -l |grep "Disk" |awk NR==1‘{print $2}‘ |awk -F"/" ‘{print $3}‘|sed s/://g`

Root=`df |awk ‘/\//{print $1}‘ |awk NR==1‘{print $1}‘`

Boot=`df |awk ‘/\/boot/{print $1}‘`

### Backup MBR

dd if=/dev/$Mbr of=$Bak_dir/mbr.img bs=512 count=1

### Backup Root [/]

dd if=$Root |gzip >$Bak_dir/root.img.gz

### Backup Boot [/boot]

dd if=$Boot |gzip >$Bak_dir/boot.img.gz


shell dd备份系统

标签:shell dd备份系统

原文地址:http://zhizhimao.blog.51cto.com/3379994/1924213

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!