A script to backup rootfs. July 14, 2013 09:51PM |
Registered: 11 years ago Posts: 149 |
(%3)(21:40)(punk)~> sudo cat /root/bin/dumpdisk #!/bin/sh if [ $# -ne 1 -a $# -ne 2 ] || [ ! -b $1 ]; then echo "`basename $0` <destination(e.g. /dev/sdc)> [hostname]" else _T=ext3 umount ${1}1 echo "`basename $0` on `date '+%Y_%m_%d'` to $1 $2" >> /root/bin/log && \ dd if=/dev/zero of=$1 bs=1M count=1 && \ sync && sync && sync && \ parted $1 --script mklabel msdos && \ parted $1 --script mkpart primary $_T 2048s 3932159s && \ mkfs.$_T ${1}1 && mount ${1}1 /mnt && cd /mnt && \ dump 0af - / | restore rf - && cd / && \ if [ $# -eq 2 ]; then _T=`hostname` sed -i "s|dc_other_hostnames='$_T'|dc_other_hostnames='$2'|" /mnt/etc/exim4/update-exim4.conf.conf sed -i "s|$_T|$2|" /mnt/etc/hostname sed -i "s|127.0.0.1\tlocalhost $_T|127.0.0.1 localhost $2|" /mnt/etc/hosts sed -i "s|$_T|$2|" /mnt/etc/mailname sed -i "s|root:x:0:0:$_T root:/root:/bin/bash|root:x:0:0:$2 root:/root:/bin/bash|" /mnt/etc/passwd sed -i "s|root:x:0:0:$_T root:/root:/bin/bash|root:x:0:0:$2 root:/root:/bin/bash|" /mnt/etc/passwd- sed -i "s|interfaces = $_T|interfaces = $2|" /mnt/etc/samba/smb.conf fi && \ sync && sync && sync && \ umount /mnt && \ tune2fs ${1}1 -U `blkid -s UUID -o value /dev/sda1` -L USBROOT && \ sync && sync && sync && \ echo "Done" fi #parted $1 --script mkpart primary $_T 2048s 3932159s && \ #parted $1 --script mkpart primary $_T 2048s -- -1 && \
Re: A script to backup rootfs. July 14, 2013 10:35PM |
Admin Registered: 13 years ago Posts: 19,200 |