[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Backing-up



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 18 October 2002 8:10 am, Oki DZ wrote:
> Hi,
>
> I'd like to backup my system; I have taken a look at amanda and afbackup.
> Unfortunately, I didn't find info on how to set the storage other than
> tapes. Is there any way to have a loop device which is a "tape drive"?
>

If you have enough disk space for a loop drive why not do something like this

This first bit creates a series of daily copies of an archive - eventually 
merging into a weekly (this runs in /etc/cron.daily) using cp -alf which 
copies hard links and and merges into what is there.  I have similar scripts 
in /etc/cron.weekly and /etc/cron.monthly - eventually putting stuff into a 
CD archive directory.

ARCH=/bak/archive

if [ -d $ARCH/daily.6 ] ; then
        if [ ! -d $ARCH/weekly.1 ] ; then mkdir -p $ARCH/weekly.1 ; fi
# Now merge in stuff here with what might already be there using hard links
        cp -alf $ARCH/daily.6/* $ARCH/weekly.1
# Finally loose the rest
        rm -rf $ARCH/daily.6 ;

fi
# Shift along snapshots
if [ -d $ARCH/daily.5 ] ; then mv $ARCH/daily.5 $ARCH/daily.6 ; fi
if [ -d $ARCH/daily.4 ] ; then mv $ARCH/daily.4 $ARCH/daily.5 ; fi
if [ -d $ARCH/daily.3 ] ; then mv $ARCH/daily.3 $ARCH/daily.4 ; fi
if [ -d $ARCH/daily.2 ] ; then mv $ARCH/daily.2 $ARCH/daily.3 ; fi
if [ -d $ARCH/daily.1 ] ; then mv $ARCH/daily.1 $ARCH/daily.2 ; fi
if [ -d $ARCH/snap ] ; then mv $ARCH/snap $ARCH/daily.1 ; fi


To do the actual backup I have a series of rsync lines similar to the 
following for each of the partitions in my system (excuse the line wrap from 
my mail composer).  What this does is back everything up, but especially 
anything in "mydocs" gets pushed into the daily archive snapshot if it 
changes, so for this special subdirectory I get daily versions back for a 
week, weekly versions back for a month and monthly versions back for 6 months 
(when I archive to CD)

# Now do home directories, but ignore nobackup directories.

rsync -aHxq --delete  --backup --backup-dir=$ARCH/snap/kanger/alan/mydocs/ 
/home/alan/mydocs/ /bak/alan/mydocs/
rsync -aHxq --delete --exclude "nobackup/" --exclude "mydocs/" /home/alan/ 
/bak/alan/

[I have deliberately put two disks in my machine with /bak being the second 
disk - this gives protection against single disk failure]

I have a similar backup running on another machine (without the archiving) so 
I need to collect their archive snapshots to add to the ones above - thus 
(using the --delete option with an empty source directory to clean out the 
destination)


rm -rf /bak/empty/*
#if we have an error at this stage it is better to exit rather than risk 
loosing some archive
set -e
rsync -aHxq roo::roo/archive/ $ARCH/snap/roo
rsync -axq --delete /bak/empty/ roo::roo/archive



Finally, to show that you can do this across the network between machines I 
backup the whole archive section on another machine (since this isn't disk to 
disk backed up)


rsync -aHxq --delete $ARCH/ roo::archive/


The whole thing is completely automatic, and I only have to look in my CD 
archive directory every so often to see if there is anything I should really 
write to CD.



- -- 
Alan Chandler
alan@chandlerfamily.org.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQE9sFgNuFHxcV2FFoIRAlg3AJ9skA/2pQzOWevkpO71m19zjPGWGwCeLb2A
sE03xJMx76sKQezFfYfHVMs=
=2GlU
-----END PGP SIGNATURE-----



Reply to: