1.将以下脚本写入bat文件:执行同步并且本地只保留一周的文件.

    start /min cmd /c "C:\Users\user1\AppData\Local\Programs\WinSCP\WinSCP.exe" /console /script=D:\gz\52.69\bak\bitwarden-backup\server_bak.txt
    set SrcDir=D:\gz\52.69\bak\bitwarden-backup\bak
    set DaysAgo=5
    forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c rd /s /q @path"
    forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c del /f /q /a @path"

2.定义server_bak.txt文件:

    option batch continue
    option confirm off                                
    option transfer binaryoption synchdelete on        
    open sftp://appadmin:passwd@your_ip:22 
    cd /home/appadmin/bitwarden-backup/                           
    lcd D:\gz\52.69\bak\bitwarden-backup\bak\          
    synchronize local                                                                 
    close
    exit