OMG!
Thank you Martin, it's working now!
Thank you Martin, it's working now!
/log=C:\backup\AICBackup.log
"c:\backup\WinSCP\winscp.com" /command ... >>%logfile% 2>&1
-certificate
switch in open
command, but always got an error msg like Unknown switch 'certificate'.
. 2017-05-09 13:01:22.093 Configuration: c:\backup\WinSCP\WinSCP.ini
ssh-keyXXXgen -l -f /etc/ssh/ssh_host_rsa_key.pub
and put it in the command:
"c:\backup\WinSCP\winscp.com" /command "open sftp://root:root@server/ -hostkey=""ssh-rsa 2048 1g:f3:e2:bc:35:ff:19:2f:a6:6f:d1:82:e6:af:1c:9c""" "put c:\AIC_Backup\Archive\AIC_Backup.7z /data1/backup/AIC/AIC_Backup.7z" "exit" "/log=AICBackup.log" "/loglevel=1"
winscp
command, just from .bat (>>%logfile% 2>&1
). In attachment I uploaded the log when I run it with clicking on backup.bat
. Do you see maybe anything wrong in it?
-hostkey
switch, what is covered in the FAQ above and also here:
winscp
command. So it's working only if I double click on backup.bat
.
@echo off
title Backup
SET logfile=C:\backup\Backup.log
echo ------------------------START Backup------------------------ >>%logfile% 2>&1
date /T >>%logfile% 2>&1
time /T >>%logfile% 2>&1
if not exist "C:\Backup" mkdir C:\Backup
if not exist "C:\Backup\Archive" mkdir C:\Backup\Archive
echo -----copy----- >>%logfile% 2>&1
xcopy C:\\design\* C:\Backup\design\* /y /s
del /F /Q c:\AIC_Backup\Archive\*
"c:\backup\7-Zip\7z" a -r C:\Backup\Archive\Backup.7z C:\AIC_Backup\*
echo errorlevel: %ERRORLEVEL%
IF %ERRORLEVEL% == 0 GOTO OK
echo.
echo !!! ERROR There was a problem during zip procedure. ErrorLevel = %ERRORLEVEL%
echo.
GOTO end
:OK
echo ------------------------Archive Done------------------------ >>%logfile% 2>&1
echo ------------------------Start Uploading------------------------ >>%logfile% 2>&1
"c:\Program Files (x86)\WinSCP\winscp.com" /command "open sftp://root:root@server/" "put c:\Backup\Archive\Backup.7z /data1/backup/Backup.7z" "exit" "/log=Backup.log" "/loglevel=1"
echo ------------------------Uploading Done------------------------ >>%logfile% 2>&1
:end
echo ------------------------Backup Done------------------------ >>%logfile% 2>&1