windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证

Posted suffergtf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证相关的知识,希望对你有一定的参考价值。

一、安装cwrsync

技术分享图片技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

二、创建密钥对,实现ssh免密码验证

linux服务器上

[[email protected] ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):       ###回车
Created directory /root/.ssh.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again:         ###回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:      ####回车
fc:68:38:67:fd:d4:7f:3b:e7:67:93:ed:e2:c0:a9:25 [email protected]
The keys randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|       .         |
|        S        |
|       . + . o   |
|      o = E * . o|
|       =   * ..=*|
|          . ...*@|
+-----------------+

[[email protected] ~]# ssh-copy-id [email protected]
The authenticity of host ‘localhost (::1)‘ can‘t be established.
ECDSA key fingerprint is e5:07:2a:f0:9f:c5:df:64:70:61:6a:7a:31:bf:21:7a.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘[email protected]‘"
and check to make sure that only the key(s) you wanted were added.

[[email protected] ~]# ls .ssh/
authorized_keys  id_rsa  id_rsa.pub  known_hosts
###########将id_rsa下载到本地

三、编辑远程copy脚本

 SETLOCAL
 SET CWRSYNCHOME=D:cwRsync    ####cwrsync安装路径
 SET HOME=D:cwRsync      ######服务器密钥rd_rsa路径,我的路径为D:cwRsync.ssh
 SET CWOLDPATH=%PATH%
 SET PATH=%CWRSYNCHOME%BIN;%PATH%
cd D:cwRsyncin
rsync -avz --delete /cygdrive/d/test [email protected]:/tmp ######/cygdrive是路径格式,我的实际路径为d:/test。
#########首次运行脚本需要手动输入一次密码########

四、定时运行

  • 创建基本任务

技术分享图片

  • 创建触发器,任务执行条件

 

 技术分享图片

  • 具体执行时间

技术分享图片

  •  触发条件后需要做哪些操作

 技术分享图片

  • 如果是打开程序,运行脚本,请选择程序、脚本路径

技术分享图片

 





















以上是关于windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证的主要内容,如果未能解决你的问题,请参考以下文章

windows rsync传输到linux备份

如何使用 rsync 将 Windows 上的文件备份到 Linux 服务器上

windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证

用samba和Microsoft Sync Toy从linux备份日志文件到windows

Linux 系统定时拷贝(发送)文件到 windows 系统,实现异地备份

Linux 系统定时拷贝(发送)文件到 windows 系统,实现异地备份