目标服务器(远程服务器):CentOS 6
终端(本地服务器):CentOS 7
任务:rsync命令远程备份数据
操作步骤如下:
[root@localhost sky9890]# yum install rsync -y
[root@localhost src]# rsync -av /usr/local/src/nginx-1.14.0.tar.gz root@113.195.***.***:/data/backup/
ssh: connect to host 113.195.***.*** port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
#远程服务器,查看22端口是否开放
[root@sky9896 backup]# vi /etc/ssh/sshd_config
#Port 22 #取消注释
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
[root@sky9896 backup]# service sshd restart
[root@localhost src]# rsync -av /usr/local/src/nginx-1.14.0.tar.gz root@113.195.**.**:/data/backup/
The authenticity of host '113.195.***.*** (113.195.***.***)' can't be established.
RSA key fingerprint is SHA256:lWE2Av+l5rc79Ssh306995hDmU8T3mMF4+a1I0DtINg.
RSA key fingerprint is MD5:7e:bd:bf:1c:f3:9f:80:26:da:f1:4c:86:43:b3:6a:e3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '113.195.***.***' (RSA) to the list of known hosts.
root@113.195.***.***'s password:
Permission denied, please try again. #拒绝登录,重新输入密码
root@113.195.***.***'s password:
sending incremental file list
nginx-1.14.0.tar.gz
sent 1,016,615 bytes received 34 bytes 27,853.40 bytes/sec
total size is 1,016,272 speedup is 1.00
#测试结果
[root@sky9896 backup]# pwd
/data/backup
[root@sky9896 backup]# ll nginx-1.14.0.tar.gz
-rw-r--r-- 1 root root 1016272 4月 17 23:35 nginx-1.14.0.tar.gz
rsync、scp命令都具有远程备份数据的作用。
scp:https://blog.51cto.com/sky9896/2120139
转载于:https://blog.51cto.com/sky9896/2171214