waja revised this gist 12 years ago. Go to revision
1 file changed, 2 insertions
sync_bare2xen.sh
| @@ -30,7 +30,9 @@ rsync -avz --numeric-ids --delete root@${1}:/dev/ /mnt/${1}/dev/ | |||
| 30 | 30 | rsync -avz --numeric-ids --delete --exclude=inittab --exclude=network/interfaces --exclude=fstab root@${1}:/etc/ /mnt/${1}/etc/ | |
| 31 | 31 | rsync -avz --numeric-ids --delete root@${1}:/home/ /mnt/${1}/home/ | |
| 32 | 32 | rsync -avz --numeric-ids --delete root@${1}:/initrd/ /mnt/${1}/initrd/ | |
| 33 | + | rsync -avz --numeric-ids --delete root@${1}:/lib32/ /mnt/${1}/lib32/ | |
| 33 | 34 | rsync -avz --numeric-ids --delete root@${1}:/lib/ /mnt/${1}/lib/ | |
| 35 | + | rsync -avz --numeric-ids --delete root@${1}:/lib64 /mnt/${1}/lib64 | |
| 34 | 36 | rsync -avz --numeric-ids --delete root@${1}:/media/ /mnt/${1}/media/ | |
| 35 | 37 | rsync -avz --numeric-ids --delete root@${1}:/mnt/ /mnt/${1}/mnt/ | |
| 36 | 38 | rsync -avz --numeric-ids --delete root@${1}:/opt/ /mnt/${1}/opt/ | |
waja revised this gist 12 years ago. Go to revision
1 file changed, 60 insertions
sync_bare2xen.sh(file created)
| @@ -0,0 +1,60 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | if [ -f /etc/default/backuppc-helper ] | |
| 3 | + | then | |
| 4 | + | . /etc/default/backuppc-helper | |
| 5 | + | if [ -z "$VOL" ] | |
| 6 | + | then | |
| 7 | + | echo "#### WARNING ####" | |
| 8 | + | echo "VOL in /etc/default/backuppc-helper not set!" | |
| 9 | + | echo "#################" | |
| 10 | + | exit 0 | |
| 11 | + | fi | |
| 12 | + | else | |
| 13 | + | echo "#### WARNING ####" | |
| 14 | + | echo "/etc/default/backuppc-helper is missing!" | |
| 15 | + | echo "#################" | |
| 16 | + | exit 0 | |
| 17 | + | fi | |
| 18 | + | ||
| 19 | + | if [ `mount | grep ${1} | wc -l` -gt "0" ] ; then | |
| 20 | + | echo "#### WARNING ####" | |
| 21 | + | echo "/dev/${VOL}/${1}-disk already mounted!" | |
| 22 | + | echo "#################" | |
| 23 | + | exit 0 | |
| 24 | + | fi | |
| 25 | + | mkdir -p /mnt/${1} | |
| 26 | + | mount /dev/${VOL}/${1}-disk /mnt/${1} | |
| 27 | + | ||
| 28 | + | rsync -avz --numeric-ids --delete root@${1}:/bin/ /mnt/${1}/bin/ | |
| 29 | + | rsync -avz --numeric-ids --delete root@${1}:/dev/ /mnt/${1}/dev/ | |
| 30 | + | rsync -avz --numeric-ids --delete --exclude=inittab --exclude=network/interfaces --exclude=fstab root@${1}:/etc/ /mnt/${1}/etc/ | |
| 31 | + | rsync -avz --numeric-ids --delete root@${1}:/home/ /mnt/${1}/home/ | |
| 32 | + | rsync -avz --numeric-ids --delete root@${1}:/initrd/ /mnt/${1}/initrd/ | |
| 33 | + | rsync -avz --numeric-ids --delete root@${1}:/lib/ /mnt/${1}/lib/ | |
| 34 | + | rsync -avz --numeric-ids --delete root@${1}:/media/ /mnt/${1}/media/ | |
| 35 | + | rsync -avz --numeric-ids --delete root@${1}:/mnt/ /mnt/${1}/mnt/ | |
| 36 | + | rsync -avz --numeric-ids --delete root@${1}:/opt/ /mnt/${1}/opt/ | |
| 37 | + | rsync -avz --numeric-ids --delete root@${1}:/root/ /mnt/${1}/root/ | |
| 38 | + | rsync -avz --numeric-ids --delete root@${1}:/sbin/ /mnt/${1}/sbin/ | |
| 39 | + | rsync -avz --numeric-ids --delete root@${1}:/srv/ /mnt/${1}/srv/ | |
| 40 | + | #rsync -avz --numeric-ids --delete root@${1}:/sys/ /mnt/${1}/sys/ | |
| 41 | + | rsync -avz --numeric-ids --delete root@${1}:/tmp/ /mnt/${1}/tmp/ | |
| 42 | + | rsync -avz --numeric-ids --delete root@${1}:/usr/ /mnt/${1}/usr/ | |
| 43 | + | rsync -avz --numeric-ids --delete root@${1}:/var/ /mnt/${1}/var/ | |
| 44 | + | ||
| 45 | + | mount --bind /proc /mnt/${1}/proc/ | |
| 46 | + | mount --bind /dev /mnt/${1}/dev | |
| 47 | + | mount --bind /sys /mnt/${1}/sys | |
| 48 | + | chroot /mnt/${1} aptitude -y purge initramfs-tools linux-image-2.6-486 linux-image-2.6.18-4-486 linux-image-2.6.18-5-486 linux-image-2.6.18-6-486 udev grub console-common console-data console-tools smartmontools hddtemp shorewall | |
| 49 | + | chroot /mnt/${1} aptitude -y install libc6-xen | |
| 50 | + | # chroot /mnt/${1} aptitude -y install linux-modules-2.6.18-6-xen-686 | |
| 51 | + | ||
| 52 | + | umount /mnt/${1}/proc/ | |
| 53 | + | umount /mnt/${1}/dev/ | |
| 54 | + | umount /mnt/${1}/sys/ | |
| 55 | + | rm -rf /mnt/${1}/var/lib/initramfs-tools/* | |
| 56 | + | rm -rf /mnt/${1}/boot/* | |
| 57 | + | rm -rf /mnt/${1}/sys/* | |
| 58 | + | rm -rf /mnt/${1}/proc/* | |
| 59 | + | rm -f /mnt/${1}/etc/udev/rules.d/z25_persistent-net.rules | |
| 60 | + | umount /mnt/${1} | |