On Friday 29 August 2003 06:21 am, Peter Ruskin wrote:
> Hi Stephen,
>
> I obviously didn't make myself clear enough.
>
> I have one disk dedicated to backups.
>
> This is the backup script my-rsync, which I put in /usr/local/bin:
> #====================================================================
>== #! /bin/bash
> # /usr/local/bin/my-rsync
> #######################
> # Backup Script
> #######################
>
> BACKUP_TO=/mnt/backup
> EXCLUDE=/usr/local/bin/rsync-exclude
>
> echo "   Mounting boot partition..."
> mount /boot -o ro
> echo
> echo "   Mounting backup disk..."
> mount $BACKUP_TO
> sleep 4
> echo
> echo "   Performing backup..."
> echo
> rsync --progress --delete -av --exclude-from=$EXCLUDE / \
>       $BACKUP_TO/rsync/
>
> echo
> echo "   Unmounting boot and backup partitions..."
>
> /bin/umount -l /boot
> /bin/umount -l $BACKUP_TO
>
> echo
> echo "   Spinning down backup disk..."
> /sbin/hdparm -y /dev/hdc                # spin down disk
> #====================================================================
>==
>
> As root, I did:
> chmod a+x /usr/local/bin/my-rsync
> ...to make the script executable
>
> In the script you'll see "EXCLUDE=/usr/local/bin/rsync-exclude". 
> This means that you list all the files you want to exclude from the
> backup in a file you create (I called mine rsync-exclude and put it
> in /usr/local/bin).  See `man rsync` for more information.
>
> My /usr/local/bin/rsync-exclude looks like this:
> #====================================================================
>== - /tmp/
> - /var/lib/init.d/
> - /mnt/backup/
> - /mnt/cdrom/
> - /mnt/floppy/
> - /proc/
> - /usr/portage/distfiles/
> - /root/.ccache/
> - /home/peter/.ccache/
> #====================================================================
>==
>
> As Andrew Farmer suggested, you can use /etc/cron.daily to have it
> run automatically.  Before you do so, run it manually to make sure it
> works for you, altering the mountpoint ($BACKUP_TO) and /dev/hdc in
> the "spin down disk" part to suit your installation.  My /etc/fstab
> entry for $BACKUP_TO reads:
> /dev/hdc1 /mnt/backup ext3 noauto,noatime,users 0 0
> ...so, like /boot, it's only mounted when needed.
>
> When you are ready to add the backup script to cron.daily, become
> root and do:
> cp /usr/local/bin/my-rsync /etc/cron.daily/
>
> Hope this helps you.
>
> Peter


Peter,
        Your script looks like it might do the trick for me. I do have a couple 
of questions though. How would I adapt it for a remote backup location? 
/mnt/backup is a normally unmounted disk on my secondary Gentoo box. I 
have configured passwordless ssh between USER with sudo privledges on 
the machine to be backed up, to [EMAIL PROTECTED] The way to ssh in to 
the remote box, mount /mnt/backup and then do the rsync eludes me. I 
wonder if you might steer me in the right direction.
        The second question is about the rsync command in your script. What 
does the --delete option do? Does it delete old backups? Forgive me for 
being a bit dense here, but I'm rather new at scripting.
-- 
Regards, Ernie
100% Microsoft and Intel free


--
[EMAIL PROTECTED] mailing list

Reply via email to