我不懂Linux,更谈不上编程,所以请原谅我的无知。
我有这个脚本,并希望有人向我解释内部。
我明白这个语法:
30 1 * * * /root/dobackup.daily /shared/svnrepos WOWSERVER /shared/backup/svnrepos
在服务器上的/ shared / svnrepos的1:30处执行rysnc备份到远程WOWSERVER,并将其放置在WOWSERVER上的/ shared / backup / snvrepos中。
但是,我不明白脚本中的“选项/variables/等”,希望有人能为我分解。
这是脚本:
#!/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/
command option1 option2 option3 ) command option1 option2 ) command option1 option2 ) date命令抓取date date指令中获取昨天的date man rsync )