I booted clonezilla.
I knew the system layout already so I customised my backup and restore scripts.
I first attempted to backup using dd if=/dev/system/root | bzip -9z > backup.bz2 but that was slow and huge.
I ended up using tar to copy all the files into tar balls. I created a temp directory to mount /dev/system/root
then cd'ed to the mounted filesystem
that was all I really needed for my backup script.
My restore looked as follows
#!/bin/bashif["$1"=""];thenecho"I need a hostname and optionally a restore point if not the latest"echo"$0 <hostname>"echo"$0 <hostname>/backup-<year>-<month>-<day>_<hour>.<minute>.<second>"exitfiif["$(parted/dev/sdaprint2>/dev/null|grepprimary)"!=""];thenecho"you need to clobber /dev/sda before running this"exitfihostname=$(dirname$1)if["${hostname}"="."];thenlatest="latest"hostname=$(basename$1)elselatest=$(basename$1)fi
hostname${hostname}backup=/home/partimag/raid_backup/${hostname}/${latest}
pd(){
parted/dev/$1mklabelmsdosyes
parted/dev/$1mkpartp0%1G
parted/dev/$1mkpartp1G100%
parted/dev/$1set1booton
parted/dev/$1set1raidon
parted/dev/$1set2raidon
}
pdsda
pdsdb
restore(){echo"building $2"
mkfs.ext3$1if[-f${backup}/$2.uuid];thentune2fs$1-U$(cat${backup}/$2.uuid)fi
mkdir-p/mnt/$2
mount$1/mnt/$2cd/mnt/$2
pv${backup}/$2.tar.gz|tar-xzf-
cd
umount/mnt/$2}
rr(){
mdadm--create/dev/md/$1--metadata1.0--level=raid1--raid-devices=2$2$3<<<"yes"}
lvm(){
pvcreate$1
vgcreate$2$1
lvcreate-l100%FREE-n$3$2}
rrboot/dev/sda1/dev/sdb1
restore/dev/md/bootboot
rrlvm/dev/sda2/dev/sdb2
lvm/dev/md/lvmsystemroot
restore/dev/system/rootroot
if[!-e/dev/data/data];thenparted/dev/sdcmklabelmsdosyes
parted/dev/sdcmkpartP0%100%
parted/dev/sdcset1lvmon
lvm/dev/sdc1datadata
restore/dev/data/datadata
fi
mount/dev/system/root/mnt/root
bd(){mount--bind$1/mnt/root$1;}
bd/dev
bd/sys
bd/proc
echomount/boot>/tmp/chrootlist
echogrub-install/dev/sda>>/tmp/chrootlist
echogrub-install/dev/sdb>>/tmp/chrootlist
echoupdate-grub>>/tmp/chrootlist
echoexit>>/tmp/chrootlist
chroot/mnt/root</tmp/chrootlist
I put these scripts in a directory raid_backup that is on a disk big enough to hold the backups.
I mount the disk as /home/partimag
On my end it is a nfs mount, but that shouldn't matter.
Last edit: jeff.sadowski 2017-06-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I booted clonezilla.
I knew the system layout already so I customised my backup and restore scripts.
I first attempted to backup using dd if=/dev/system/root | bzip -9z > backup.bz2 but that was slow and huge.
I ended up using tar to copy all the files into tar balls. I created a temp directory to mount /dev/system/root
then cd'ed to the mounted filesystem
that was all I really needed for my backup script.
My restore looked as follows
I put these scripts in a directory raid_backup that is on a disk big enough to hold the backups.
I mount the disk as /home/partimag
On my end it is a nfs mount, but that shouldn't matter.
Last edit: jeff.sadowski 2017-06-09
Great! Thanks for sharing that.
Steven