Skip to main content

远程数据同步及操作方法

Winscp远程同步数据脚本

# winscp.exe /console /script=sample.txt 

# Automatically answer all prompts negatively not to stall
# the script on errors
# option echo on|off
option echo off

# option batch on|off|abort|continue
option batch on

# option confirm on|off
option confirm off

# option transfer binary|ascii|automatic
# option synchdelete on|off
# option exclude clear | <mask>[;<mask2>...]
# option include clear | <mask>[;<mask2>...]

# open [ sftp|ftp|scp:// ][ <user> [ :password ] @ ] <host> [ :<port> ]
# open user:password@example.com
# Connect FTP地址
open sftp://root:password#@42.xx.xx.xxx:22

# Change remote directory
cd /root/iskey/work/enzo2
#如果同步到远程FTP时,可用此命令转到远程某个目录下.

# Change local directory
# set to Self's working dir 设置需要同步到远程FTP的本地文件目录
lcd F:\vms\vagrant_work\Django\enzo

# Force binary mode transfer
option transfer ascii

# Download file to the local directory d:\
# get examplefile.txt d:\

# option synchdelete on|off
option synchdelete off

# option include clear | <mask>[;<mask2>...]
synchronize remote -filemask="|*.pyc; .git\; .idea\; .cache\; .autojump\; .\idea\; .local\; .ipython\; venv\"


# synchronize local|remote|both [ <local directory> [ <remote directory> ] ] 从远程同步到本地用Local;从本地同步到远程用Remote
#synchronize remote

# Disconnect
close

# Exit WinSCP
exit

  • 使用命令:
C:\...\winscp577\WinSCP.exe /console /script=C:\...\enzo2.txt