Loading ...
Sorry, an error occurred while loading the content.

9792Full Drive Backup Script

Expand Messages
  • Internet User
    Nov 7, 2005
      I'm trying to immitate the full drive backup feature of the original
      linksys firmware (shame on me). I have 2 matching disk on the nslu2
      running openslug 2.7. Rsync is a awesome utiliy to accomplish such.

      I figure having two disk with the same data will serve in in two ways;

      1. a full backup requirement
      2. Openslug seems to ramdomly switch which disk will be sda and sdb
      at boot up (which kinda sucks), having a matching bootable partition
      on both disk will work around that problem.

      I have 3 partitions on each disk. 1st for rootfs, 2nd for my data
      mounted on /usr/data, 3rd for swap.

      Here is my horribly in-efficient script that I use to mount the
      second drive to /backup, copy all the folders and files using rsync,
      and unmount. I'm sure I did not do this right, but it works. Any help
      on how to properly accomplish the goal would be greatly appreciated.
      I think I don't have to copy the sys and proc directories, but am not
      sure. And I'm pretty sure the command list can be shortened also.

      mkdir /backup > /var/log/backup.log
      mount /dev/sdb1 /backup >> /var/log/backup.log
      mount /dev/sdb2 /backup/usr/data >> /var/log/backup.log
      rsync -a --
      delete /bin /dev /home /lib /mnt /root /sys /boot /etc /initrd /linuxr
      c /media /proc /sbin /tmp /var /backup/ >> /var/log/backup.log
      rsync -a --
      delete /usr/bin /usr/games /usr/include /usr/lib /usr/libexec /usr/sbi
      n /usr/share /usr/src /backup/usr/ >> /var/log/backup.log
      rm -Rf /usr/data/private/mail/backup.3 >> /var/log/backup.log
      mv /usr/data/private/mail/backup.2 /usr/data/private/mail/backup.3
      >> /var/log/backup.log
      mv /usr/data/private/mail/backup.1 /usr/data/private/mail/backup.2
      >> /var/log/backup.log
      cp -a /usr/data/private/mail/backup.0 /usr/data/private/mail/backup.1
      >> /var/log/backup.log
      rsync -a --
      delete /usr/data/private/mail/*.pst /usr/data/private/mail/backup.0/
      >> /var/log/backup.log
      rsync -a --
      delete /usr/data/erotica /usr/data/private /usr/data/public /backup/us
      r/data/ >> /var/log/backup.log
      umount /dev/sdb2 >> /var/log/backup.log
      umount /dev/sdb1 >> /var/log/backup.log
      rm -R /backup >> /var/log/backup.log

      And as you can see, I would also like a log to tell me the script was
      successful. It would be ideal if updated files could be loged also.
      But I'll take what I can get.
    • Show all 2 messages in this topic