为我解释这个rsync脚本 – Linux备份

我不懂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/ 

  • RDIR – 远程(备份)目录
  • $ 3 – 第三个命令行选项(例如command option1 option2 option3
  • EXCLUDES – 要排除的文件名
  • RSERVER – 要备份到的远程服务器
  • $ 2 – 第二个命令行选项(例如command option1 option2
  • LDIR – 要备份的本地目录
  • $ 1 – 第一个命令行选项(例如, command option1 option2
  • 今天 – 从date命令抓取date
  • YESTERDAY – 从date指令中获取昨天的date
  • OPTS – rsync的命令行选项(check man rsync
  • export PATH – 确保PATH环境variables包含rsync的可能位置
  • $ HOME – 运行脚本的用户的主文件夹(/ home / username)