猫猫1 发表于 2018-8-20 13:09:17

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
  dd if=$Boot |gzip >$Bak_dir/boot.img.gz

页: [1]
查看完整版本: shell dd备份系统