![](https://seccdn.libravatar.org/avatar/b72f250a4f5b7bc95f1e9b00f684ecc1.jpg?s=120&d=mm&r=g)
On Wednesday 16 February 2005 17:20, Ken Schneider wrote:
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
for source in $SOURCES; do if [ ! -d $TARGET/$source ]; then mkdir -p $TARGET$source fi but just commenting out this section doesn't work well. I would like to know how to eliminate this section because that would eliminate the creation of
I know. That is why I commented out: the useless directory. But as I stated in my original email just commenting it out leaves a script that doesn't seem to work as well. As a work around I changed mkdir to touch. Even though there's nothing to touch, rsync backs up the test file and doesn't create the unwanted folder. This works, but there must be a better, more standard way to do this. Jerome
$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