[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] Backup advice
> purpose. For instance, if you use the update option of copy (-u) only newer
> or new files are copied, thus solving the problem of copying existing
> files.
>
> find is also a good one for this. See `man find`
Further to my own email, try this one:
-- START --
#!/bin/sh
# List of directories to back up
dirlist="
/home/me/backupfiles"
# Root to back up to
backuproot="/tmp/backup"
# Check if backup root exists
if [ ! -d $backuproot ]
then
mkdir -p $backuproot
fi
# Loop through all directories in source list
for srcdir in $dirlist
do
# Check if source dir exists
if [ -d $srcdir ]
then
# Create all appropriate destination directories
for destdir in `find $srcdir -type d`
do
if [ ! -d $destdir ]
then
mkdir -p $backuproot$destdir
fi
done
# Copy all newer than those already there
# NB you may want to use -x here to stay on one filesystem
cp -uva $srcdir $backuproot$srcdir
else
# Oops! Invalid search directory
echo "$srcdir does not exists, or is not a directory"
fi
done
-- END --
Just put your own source directories in the dirlist declaration at the top,
and your own destination in the backuproot.
Craig
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.