【问题标题】:How to synch backup data one server to another server using script?如何使用脚本将备份数据从一台服务器同步到另一台服务器?
【发布时间】:2015-06-11 06:22:54
【问题描述】:

我在 /backup 文件夹中有一个 WHM 面板数据,我想复制远程服务器上的所有数据。请提供脚本,如何在脚本中使用 rsync 命令同步远程服务器上的数据并在复制完成时获取邮件?

谢谢

【问题讨论】:

  • SO 不是要求人们为您编写整个程序的地方。您需要展示解决您遇到的特定问题的合法尝试,例如你不明白某些东西是如何工作的,你无法通过错误消息等等。
  • 更多信息请见How do I ask a good question?

标签: linux sh cpanel rsync whm


【解决方案1】:

这是我使用的 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

https://gist.github.com/treehousetim/2a7871f87fa53007f17e

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2013-07-25
    • 2022-01-04
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多