On Tue Aug 19, Voytek Eymont wrote:
> what should I use to mirror user data to another Linux machine ?
> I need to initially copy the whole dir, and then, once in a while, check
> for updated docs, and, copy any updated or new files
This is a script that I use to transfer mail from one machine to
another.
#!/bin/sh
# This will rsync mail from Martel to Casteret - you must be on Casteret.
# Check if we are on casteret, if not exit.
if [ $HOSTNAME != casteret ]; then
echo "You are on $HOSTNAME".
echo "You must be on casteret to run this script."
exit 1
fi
echo "This will rsync mail from Martel to Casteret"
echo "Continue (y/Y) or press any other key to exit?"
# We have to check for a reply!
read REPLY
if [ -z $REPLY ]; then
echo "You didn't enter anything; try again next time."
exit 1
fi
# If user has NOT selected y/Y then exit.
if [ $REPLY != "y" ] && [ $REPLY != "Y" ]; then
exit 0
fi
# Otherwise we continue.
rsync -rlv --existing [EMAIL PROTECTED]:Mail/* /home/mikel/Mail/
and here is another script that copies mail over where I dont want to
over write existing mail.
#!/bin/sh
# Check if we are on martel, if not exit.
if [ $HOSTNAME != martel ]; then
echo "You are on $HOSTNAME".
echo "You must be on martel to run this script."
exit 1
fi
# This will check that all the mail files in the directory are of zero length
# i.e. they have already been read and saved away and we wont be writing over
# the top of previous mail.
# (try instead ls -s only )
if [ `ls -l | tr -s ' ' | cut -d ' ' -f5,9 | grep -v copy | cut -d ' ' -f1 | grep -v
0` ]; then
echo 'There are non empty mail files! This program will exit.'
ls -l | tr -s ' ' | cut -d ' ' -f5,6,7,9
echo
exit
fi
echo "This will rsync existing mail files from:"
echo "Casteret/Mozilla/Triode Folder --> Martel/Mutt/Casteret Folder"
echo "Continue (y/Y) or press any other key to exit?"
# We have to check for a reply!
read REPLY
if [ -z $REPLY ]; then
echo "You didn't enter anything; try again next time."
exit 1
fi
# If user has NOT selected y/Y then exit.
if [ $REPLY != "y" ] && [ $REPLY != "Y" ]; then
exit 0
fi
# Otherwise we continue.
rsync -rlv --existing [EMAIL PROTECTED]:.mozilla/Mail/mail.triode.net.au/*
/home/mikel/Mail/From_Casteret/
echo
echo "Finished"
echo
-
That should also show you how to use rsync :-)
--
Executive ability is prominent in your make-up.
Mike Lake
Caver, Linux enthusiast and interested in anything technical.
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug