【发布时间】:2015-06-11 06:22:54
【问题描述】:
我在 /backup 文件夹中有一个 WHM 面板数据,我想复制远程服务器上的所有数据。请提供脚本,如何在脚本中使用 rsync 命令同步远程服务器上的数据并在复制完成时获取邮件?
谢谢
【问题讨论】:
-
SO 不是要求人们为您编写整个程序的地方。您需要展示解决您遇到的特定问题的合法尝试,例如你不明白某些东西是如何工作的,你无法通过错误消息等等。
我在 /backup 文件夹中有一个 WHM 面板数据,我想复制远程服务器上的所有数据。请提供脚本,如何在脚本中使用 rsync 命令同步远程服务器上的数据并在复制完成时获取邮件?
谢谢
【问题讨论】:
这是我使用的 rsync shell 脚本。它放在我的项目中名为/publish 的文件夹中。
gist 包含 shell 脚本提到的 rs_exclude.txt 文件。
您可能还对using ssh keys 感兴趣,因此您不必每次都输入密码
# reverse the comments on the next two lines to do a dry run
#dryrun=--dry-run
dryrun=
c=--compress
exclude=--exclude-from=rs_exclude.txt
pg="--no-p --no-g"
#delete is dangerous - use caution. I deleted 15 years worth of digital photos using rsync with delete turned on.
# reverse the comments on the next two lines to enable deleting
#delete=--delete
delete=
rsync_options=-Pav
rsync_local_path=../
rsync_server_string=user@example.com
rsync_server_path="/home/www.example.com"
# choose one.
#rsync $rsync_options $dryrun $delete $exclude $c $pg $rsync_local_path $rsync_server_string:$rsync_server_path
#how to specify an alternate port
#rsync -e "ssh -p 2220" $dryrun $delete $exclude $c $pg $rsync_local_path $rsync_server_string:$rsync_server_path
【讨论】: