Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I don't know Linux and even less about programming so pardon my ignorance.

I have this script and would like someone to explain the internals to me.

I understand that the syntax of:

30 1 * * * /root/dobackup.daily /shared/svnrepos WOWSERVER /shared/backup/svnrepos

does an rysnc backup at 1:30 of /shared/svnrepos on the server to the remote WOWSERVER and places it in the /shared/backup/snvrepos on the WOWSERVER.

However, I don't understand the "options/variables/etc" in the script and was hoping someone could break it down for me, please.

Here's the script:

#!/bin/sh

# This script does personal backups to a rsync backup server. You will end up
# with a 7 day rotating incremental backup. The incrementals will go
# into subdirectories named after the day of the week, and the current
# full backup goes into a directory called "current"
# tridge@linuxcare.com

# directory to backup

if [ $# != 3 ]; then
        echo "Syntax is \"dobackup.daily {LocalDir} {RemoteServer} {RemoteDir}\""
        exit
fi

#RDIR=/shared/backup/CADData
RDIR=$3

# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=

# the name of the backup machine
#RSERVER=TESTSERVER
RSERVER=$2

#LDIR=/shared/CADData
LDIR=$1

# your password on the backup server
#export RSYNC_PASSWORD=XXXXXX


########################################################################

TODAY=`date +%A`
YESTERDAY=`date --date=yesterday +%A`

#TODAY=test3
#YESTERDAY=Monday

OPTS="--link-dest=../$YESTERDAY --timeout=999 -aAz"

        export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

        # the following line clears the last weeks incremental directory
#      [ -d $HOME/emptydir ] || mkdir $HOME/emptydir
#      rsync --delete -aAz -e 'ssh -c blowfish -i /root/.ssh/backup -ax -o ClearAllForwardings=yes' $HOME/emptydir/ $RSERVER:$RDIR/$BACKUPDIR/
#      rmdir $HOME/emptydir

        # now the actual transfer
        rsync $OPTS -e 'ssh -c blowfish -i /root/.ssh/4to5 -ax -o ClearAllForwardings=yes' $LDIR/ $RSERVER:$RDIR/$TODAY/
share|improve this question

1 Answer 1

up vote 2 down vote accepted
  • RDIR - Remote (backup) directory
  • $3 - The third command line option (e.g. command option1 option2 option3)
  • EXCLUDES - file names to exclude
  • RSERVER - The remote server to back up to
  • $2 - The second command line option (e.g. command option1 option2)
  • LDIR - The local directory to back up
  • $1 - The first command line option (e.g. command option1 option2)
  • TODAY - Grabs the date from the date command
  • YESTERDAY - Grabs yesterday's date from the date command
  • OPTS - Command line options for rsync (check man rsync)
  • export PATH - makes sure that the PATH environment variable contains the likely location of rsync
  • $HOME - the home folder (/home/username) of the user running the script
share|improve this answer
    
Thank you very much! –  TheCleaner May 19 '11 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.