On Wed, 2005-02-16 at 20:38, Susemail wrote:
I have a shell script that I use to backup my main computer to hard drives connected to it. I edited it today to backup another computer over my Lan. This is the script:
#!/bin/sh # backup.sh -- backup to a local drive using rsync
# Directories to backup. Separate with a space. Exclude trailing slash! SOURCES="apollo@Linux:Test/"
# Directory to backup to. This is where your backup(s) will be stored. TARGET="/data1/LinuxBackup"
EXCLUDE_FILE="/home/apollo/rsync_exclude_file"
# Comment out the following line to disable verbose output VERBOSE="-v" ###########################
if [ -f $EXCLUDE_FILE ]; then EXCLUDE="--exclude-from=$EXCLUDE_FILE" fi
for source in $SOURCES; do if [ ! -d $TARGET/$source ]; then mkdir -p $TARGET$source fi rsync $VERBOSE $EXCLUDE -avz -e ssh --delete $source/ $TARGET/ done
This works. It puts a copy of the test file in /data1/LinuxBackup. It also produces a directory called: 'LinuxBackupapollo@Linux:Test' in /data1 that I don't want.
But that is what you are telling it to create with "mkdir -p $TARGET$source" $TARGET=/data1/LinuxBackup and $source=(actually it is not defined, $SOURCES is and ="apollo@Linux:Test/"). It appears you left out the "/" between $TARGET and $source so you are getting what you defined. If you want to further trouble shoot your source include echo statements for your variables to see if what you want is what you are going to get. I.E. echo $TARGET $source -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 * Only reply to the list please* "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." -Ernst Jan Plugge