Backups completely filling root drive.

Tony Arnold tony.arnold at manchester.ac.uk
Wed Sep 27 19:27:07 UTC 2006


Larry,

On Wed, 2006-09-27 at 09:09 -0500, Larry Alkoff wrote:

> This is the rsync script.  There is a little wrapping in places since my 
> mailer limits the line length.

I can't see anything obviously wrong with this script. A minor point is
that you include $TESTING when you echo the rsync command to the log
file, but it's not there in the rsync command itself.

Have you tried it and does it work? I imagine it should!

Regards,
Tony.
> 
> 
> root at kinda bin # cat mirrorkub
> #!/bin/bash
> # lba: mirrorkub - use rsync to update a hard disk
> 
> 
> # Variables:
> #TESTING=--dry-run
> TESTING=
> MIRROR=/mnt/mirror
> # TEE=2>&1 |tee >>/var/log/mirror.log
> TEE='tee >>/var/log/mirror.log'
> 
> 
> # First prepare a similiar mirror hard disk using dd - for example:
> # dd if=/dev/hda of=/dev/hdb bs=16M
> 
> # make sure we're running as root
> if [ `/usr/bin/id -u` != 0 ]; then { /bin/echo "Sorry only root can do 
> this.  Exiting..."; exit 1; } fi
> 
> # Only -n parameter allowed
> if [ ! $1 = "-n" ]; then
>          echo Bad parameter.  Aborting!
>          exit 1
> fi
> 
> 
> 
> if [ ! -d $MIRROR ]; then mkdir $MIRROR; fi
> if [ ! -d $MIRROR/home ]; then mkdir $MIRROR/home; fi
> # if [ ! -d $MIRROR/extra ]; then mkdir $MIRROR/extra; fi
> 
> 
> echo Mounting all the mirror disk partitions:
> mount -v $MIRROR                2>/dev/null
> mount -v $MIRROR/home           2>/dev/null
> # mount -v $MIRROR/extra                2>/dev/null
> 
> ## exit         # enable to mount only
> 
> # Delete the last log:
> # rm /var/log/mirror.log
> 
> # Display banner:
> #echo "Mirror: started2 `/usr/bin/date`" >>/var/log/mirror.log
> 
> echo "" >>/var/log/mirror.log
> echo 
> "***********************************************************************" 
>  >>/var/log/mirror.log
> echo "" >>/var/log/mirror.log
> echo -n "       Mirror: " >>/var/log/mirror.log
> echo -n "started " >>/var/log/mirror.log
> date +"%A    %B %e, %Y    %l:%M %P    doy=%j" >>/var/log/mirror.log
> echo "" >>/var/log/mirror.log
> echo 
> "***********************************************************************" 
>  >>/var/log/mirror.log
> echo "" >>/var/log/mirror.log
> echo
> 
> # Loop to update the selected directories:
> #       Note: The trailing / for SOURCE ( eg: /bin/ ) is _crucial_!
> # ----------------------------------------
> ## for SOURCE in  /bin/ /boot/ /dev/ /etc/ /home/ /lib/ /opt/ /root/ 
> /sbin/ /usr/ /var/ /extra/ ; do
> ## 6/25/05 Eliminated /extra bec it takes 4 hours! rsync line problem?
> 
> # These are _all_ the root directories of Kubuntu:
>          ###  Which ones to include ??  What does /srv/ do?
> # /bin/ /boot/ /dev/ /etc/ /home/ /initrd/ /lib/ /lost+found/ /media/ \
> # /mnt/ /opt/ /proc/ /root/ /sbin/ /srv/ /sys/ /tmp/ /usr/ /var/
> 
> # For ubuntu:
> for SOURCE in /bin/ /boot/ /dev/ /etc/ /home/ /initrd/ /lib/ \
>          /opt/ /root/ /sbin/ /srv/ /usr/ /var/ ; do
>        # Does not include /lost+found/ /media/ /mnt/ /proc/ /sys/  /tmp/
> 
>      echo "Working in $SOURCE ................................... $SOURCE"
>      echo >>/var/log/mirror.log
>      echo -n "`date` " >>/var/log/mirror.log
>      echo -n "Working in $SOURCE: " >>/var/log/mirror.log
> 
>    EXCLUDE=
>    if [ $SOURCE = "/home/" ]; then
> #     EXCLUDE="--exclude lba/.opera/cache4/"
>       EXCLUDE="--exclude lba/.opera/cache4/  --exclude lba/Muttmail/ 
> --exclude lba/dl/"
>       # note: --exclude is relative to the source path.  Above works!
>    fi
> 
> # add cH to options
> 
>     echo "command: rsync -uacHv $1 --delete $TESTING $EXCLUDE $SOURCE 
> $MIRROR$SOURCE" >>/var/log/mirror.log
>     rsync -uacHv $1 --delete $EXCLUDE $SOURCE $MIRROR$SOURCE 
>  >>/var/log/mirror.log
>       # eliminated --progress (too much verbiage), --stats
> done
> 
> echo  Unmounting all the mirror disk partitions:
> # umount -v $MIRROR/extra       2>/dev/null
> umount -v $MIRROR/home          2>/dev/null
> umount -v $MIRROR/              2>/dev/null
> 
> echo  Removing all the mirror disk partitions:
> # rmdir -p $MIRROR/extra
> rmdir -p $MIRROR/home
> rmdir    $MIRROR
> 
> 
> if [ isdir = 0 ]; then
>          echo Something went wrong - partitions did not unmount 
>  >>/var/log/mirror.log
> else
>          echo Partitions ummounted sucessfully >>/var/log/mirror.log
> fi
> 
> echo "" >>/var/log/mirror.log
> echo 
> "***********************************************************************" 
>  >>/var/log/mirror.log
> echo "Mirror: completed " `date` >>/var/log/mirror.log
> echo "    Log is in /var/log/mirror.log"
> echo 
> "***********************************************************************" 
>  >>/var/log/mirror.log
> echo "" >>/var/log/mirror.log
> 
> exit 0
> 
> # Information on rsync options:
> # -----------------------------
> # I am using rsync -uacHv
> 
> 
> # List of options:
> #  -a = -rlptgoD
> #       -r = recurse
> #       -l = copy symlinks as symlinks
> #       -p = preserve permissions
> #       -t = perserve times
> #       -g = preserve group
> #       -o = preserve owner   (root only)
> #       -D = preserve devices (root only)
> # -u = update
> # -c = compare checksum of source and target
> # -H = preserve hard links
> # --stats = display statistics
> # --exclude = exclude PATTERN (relative to source path)
> # -b --backup = backup changed files with default ~
> # --suffix = backup suffix other than ~
> # --log-format = format like man rsyncd.conf
> # --progress = display progress
> # --delete = delete files on $MIRROR that do not exist on source
> #            Can be dangereous - do dry-run first!
> # --force = force deletion of directories even if not empty
> 
> 
> 
> -- 
> Larry Alkoff N2LA - Austin TX
> Using Thunderbird on Linux
> 
-- 
Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at manchester.ac.uk, H: http://www.man.ac.uk/Tony.Arnold




More information about the ubuntu-users mailing list