Mailinglist Archive: opensuse (2912 mails)

< Previous Next >
Re: [SLE] Shell backup script
  • From: Susemail <susemail@xxxxxxxxxxxxx>
  • Date: Wed, 16 Feb 2005 21:54:18 -1000
  • Message-id: <200502162154.18159.susemail@xxxxxxxxxxxxx>
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

I know. That is why I commented out:
> > 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
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

< Previous Next >
References