rsync实现断点续传

当要传送文件较大,过程中如果网络中断了,就比较悲剧了。这时候可以考虑使用rsync命令替代scp,P实现断点续传文件。
rsync -rP --rsh=ssh /home/oracle/TestDB/ oracle@192.168.1.173:/home/oracle/TestDB
--/bin/rsync -avz --password-file=/etc/rsyncd.pas rsyncuser@192.168.10.20::backup /home/nas/

推送本地文件到远程
rsync -avz /cygdrive/e/sinafund_loadoffpay.txt 10.0.225.246::di/data
rsync -avz /Users/zhaoyang10/Documents/mis_file/wbad_client_adplanlog_day.txt 10.0.0.246::di/data
rsync -avz /Users/zhaoyang10/Documents/mis_file/wbad_client_adplanlog_day.txt 10.0.20.11::di/data

拉取远程文件到本地
rsync -avz 10.0.0.246::di/data/wbad_client_adplanlog_day.txt /Users/zhaoyang10/Documents
rsync -avz 10.0.225.11::di/dailycheck/iad/wbad_client_adplanlog_day_20190326.txt /Users/zhaoyang10/Documents
rsync -avz 10.0.225.11::di/data/wbad_client_adplanlog_day.txt /Users/zhaoyang10/Documents

查看远程服务器目录下所有文件
rsync -v rsync://10.0.225.246:/di/data/
rsync -v rsync://10.0.225.11:/di/data/
rsync -v rsync://10.0.225.246:/di/dailycheck/iad/
rsync -v rsync://10.0.225.11:/di/dailycheck/iad/

RSYNC_PASSWORD=dbzeaRJ1Ob2OzxxxxaGy1VDJdPkUpsP8S2oeoF3XiPuf5fY= rsync --list-only xx@r2.xxx.com.cn::wb_ad_cust_deliver_consume/201905/06/

有密码推送:
密码文件:pwd.cfg文件权限必须为600,内容: dbzeaRJ1Ob2xxxxOzaGy1VDJdPkUpsP8S2oeoF3XiPuf5fY=

生产环境脚本:
rsync -avP --timeout=180 --password-file=/data/logs/file/mis_file/pwd.cfg /data/logs/file/mis_file/201904/16 xxx@r2.xxx.com.cn::wb_ad_cust_deliver_consume/201904

posted @ 2020-09-30 17:38  ritchy  阅读(1773)  评论(0编辑  收藏  举报