问题描述:

I have one WHM panel data in /backup folder, I want to copy all data On remote server. Please provide me the script, how to use rsync command In script to sync data on a remote server and get the mail when the copy is Completed?

Thanks

网友答案:

Here is the rsync shell script that I use. It is placed in a folder named /publish in my project.

The gist contains the rs_exclude.txt file the shell script mentions.

You might also be interested in using ssh keys so you don't have to type your password each time

# 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=../
[email protected]
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

相关阅读:
Top