rsync or replacement backup

Mike Bird mgb-ubuntu at yosemite.net
Mon May 19 20:36:26 UTC 2008


On Mon May 19 2008 12:58:01 Karl Larsen wrote:
> karl at karl-desktop:~$ cat /root/bin/backup
> # This file is designed to backup my Ubuntu to the USB Hard Drive using
> rsync
> # Karl Larsen, 26 Feb 08
> rsync -avz /boot /media/disk/

Omit the "-z".  It compresses traffic over networks but it
doesn't help with local copies.

> rsync -avz /bin  /media/disk/
> rsync -avz /dev  /media/disk/

You probably don't want to ever restore /dev, so backing it up
could be regarded as a waste of time.  However it's small and
the information from a /dev backup is sometimes useful in
emergencies so go ahead and back it up.

> rsync -avz /etc  /media/disk/
> rsync -avz /lib  /media/disk/
> rsync -avz /opt  /media/disk/
> rsync -avz /root /media/disk/
> rsync -avz /sbin /media/disk/
> rsync -avz /srv  /media/disk/
> rsync -avz /sys  /media/disk/

/sys is a special filesystem like /proc.  I wouldn't back it up.

> rsync -avz /tmp /media/disk/

Most people don't backup /tmp, /var/tmp, ... to save time and space.

> rsync -avz /usr /media/disk/
> rsync -avz /var /media/disk/
> rsync -avz /initrd /media/disk/
>
>     Of course /sbin is the current sbin directory. /media/disk/ is where
> the USB hard disk is located.
>
>      So does anyone know a good one line way to do the same thing?

Here's a one-liner.  You might want to adjust the exclusions
to suit your needs.  Make sure the correct disk is mounted on
/media/disk before starting.  [With rsync v3 you can add "-X" :-) ]

rsync -va -SHA --partial --delete --delete-excluded --exclude=/media --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/spool/squid --exclude=/var/tmp --exclude=/mnt --exclude='/home/*/.mozilla/firefox/*/Cache' / /media/disk/

--Mike Bird




More information about the ubuntu-users mailing list