Hi
I have found several posts on this topic in this forum, but somehow, none of them seems to apply to my case.
Hoping someone can point me in the right direction.
Thanks
Here is my code:
@ECHO OFF
REM
REM Backup
REM
REM Delete log file of previous day
IF EXIST C:\Scripts\boro_remote_daily.log DEL C:\Scripts\boro_remote_daily.log
REM
REM Execute the backup command.
"C:\Program Files\WinSCP\WinSCP.com" /script=C:\Scripts\boro_backup_script.txt /ini=C:\Scripts\WinSCP.ini /log=C:\Scripts\boro_remote_daily.log
IF ERRORLEVEL 1 GOTO error
REM
REM success handler
REM
REM
ECHO success.
REM Generate email header
ECHO FROM: [email protected] >> %TEMP%\temp.mail
ECHO To: [email protected]. >> %TEMP%\temp.mail
ECHO Subject: Success: The remote backup of BORO Website was successful >> %TEMP%\temp.mail
ECHO.>> %TEMP%\temp.mail
REM
REM Empty email.
REM Send email
c:\usr\lib\sendmail.exe -t < %TEMP%\temp.mail
GOTO cleanup
REM
REM error handler
REM
:error
REM
ECHO Failure.
REM Generate email header
ECHO FROM: [email protected] >> %TEMP%\temp.mail
ECHO To: [email protected]. >> %TEMP%\temp.mail
ECHO CC: [email protected]. >> %TEMP%\temp.mail
ECHO CC: [email protected]. >> %TEMP%\temp.mail
ECHO Subject: Failure: The remote backup of BORO Website failed %ERRORLEVEL% >> %TEMP%\temp.mail
ECHO.>> %TEMP%\temp.mail
REM
REM Create email file (Header + Body)
COPY /B %TEMP%\temp.mail+C:\Scripts\boro_remote_daily.log %TEMP%\temp1.mail
REM Send email
c:\usr\lib\sendmail.exe -t < %TEMP%\temp1.mail
GOTO cleanup
REM
REM Cleanup tasks
REM
:cleanup
REM
ECHO Cleanup
REM Delete email header file
IF EXIST %TEMP%\temp.mail DEL %TEMP%\temp.mail
REM
REM Delete email file
IF EXIST %TEMP%\temp1.mail DEL %TEMP%\temp1.mail
REM DEL C:\Scripts\boro_remote_daily.log
And here my WinSCP script
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch continue
# Disable overwrite confirmations that conflict with the previous
# option confirm off
option reconnecttime 10
open boro
synchronize local -criteria=time C:\Backups\BORO\Mirror\parts\instance\Extensions /opt/Plone/boro/parts/instance/Extensions
synchronize local -criteria=time C:\Backups\BORO\Mirror\parts\instance\Products /opt/Plone/boro/parts/instance/Products
synchronize local -criteria=time C:\Backups\BORO\Mirror\parts\productdistros /opt/Plone/boro/parts/productdistros
option include "/opt/Plone/boro/parts/instance/etc/zope.conf"
synchronize local -criteria=time C:\Backups\BORO\Mirror\parts\instance\etc /opt/Plone/boro/parts/instance/etc/
option include "/opt/Plone/boro/var/filestorage/Data.fs.tgz"
synchronize local -criteria=time C:\Backups\BORO\Mirror\var\filestorage /opt/Plone/boro/var/filestorage
close
exit
Log file generated:
[code:1:998099e592]. 2012-05-27 17:14:21.468 --------------------------------------------------------------------------
. 2012-05-27 17:14:21.468 WinSCP Version 4.1.9 (Build 416) (OS 5.2.3790 Service Pack 2)
. 2012-05-27 17:14:21.468 Login time: 27 May 2012 17:14:21
. 2012-05-27 17:14:21.468 --------------------------------------------------------------------------
. 2012-05-27 17:14:21.468 Session name: boro
. 2012-05-27 17:14:21.468 Host name: xx.xxx.xx.xxx (Port: 22)
. 2012-05-27 17:14:21.468 User name: boro (Password: Yes, Key file: No)
. 2012-05-27 17:14:21.468 Tunnel: No
. 2012-05-27 17:14:21.468 Transfer Protocol: SFTP (SCP)
. 2012-05-27 17:14:21.468 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2012-05-27 17:14:21.468 Proxy: none
. 2012-05-27 17:14:21.468 SSH protocol version: 2; Compression: No
. 2012-05-27 17:14:21.468 Bypass authentication: No
. 2012-05-27 17:14:21.468 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2012-05-27 17:14:21.468 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2012-05-27 17:14:21.468 SSH Bugs: -,-,-,-,-,-,-,-
. 2012-05-27 17:14:21.468 SFTP Bugs: -,-
. 2012-05-27 17:14:21.468 Return code variable: Autodetect; Lookup user groups: Yes
. 2012-05-27 17:14:21.468 Shell: default, EOL: 0
. 2012-05-27 17:14:21.468 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2012-05-27 17:14:21.468 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2012-05-27 17:14:21.468 Local directory: default, Remote directory: /home/boro, Update: No, Cache: Yes
. 2012-05-27 17:14:21.468 Cache directory changes: Yes, Permanent: Yes
. 2012-05-27 17:14:21.468 DST mode: 1
. 2012-05-27 17:14:21.468 --------------------------------------------------------------------------
. 2012-05-27 17:14:21.468 Looking up host "xx.xxx.xx.xxx"
. 2012-05-27 17:14:21.468 Connecting to xx.xxx.xx.xxx port 22
. 2012-05-27 17:14:21.531 Server version: SSH-2.0-OpenSSH_4.2p1 Debian-7ubuntu3.5
. 2012-05-27 17:14:21.531 We claim version: SSH-2.0-WinSCP_release_4.1.9
. 2012-05-27 17:14:21.578 SSPI: acquired credentials for: tchepannoue@BALDER
. 2012-05-27 17:14:21.578 Cannot convert IP address to SPN: DNS is not trusted
. 2012-05-27 17:14:21.578 GSSKEX disabled: The operation completed successfully.
. 2012-05-27 17:14:21.593 Using SSH protocol version 2
. 2012-05-27 17:14:21.609 Doing Diffie-Hellman group exchange
. 2012-05-27 17:14:21.687 Doing Diffie-Hellman key exchange with hash SHA-1
. 2012-05-27 17:14:21.953 Host key fingerprint is:
. 2012-05-27 17:14:21.953 ssh-rsa 2048 bf:37:17:5f:6d:74:80:d8:c5:3a:46:7a:7f:4f:9c:42
. 2012-05-27 17:14:21.953 Initialised AES-256 CBC client->server encryption
. 2012-05-27 17:14:21.953 Initialised HMAC-SHA1 client->server MAC algorithm
. 2012-05-27 17:14:21.953 Initialised AES-256 CBC server->client encryption
. 2012-05-27 17:14:21.953 Initialised HMAC-SHA1 server->client MAC algorithm
! 2012-05-27 17:14:22.046 Using username "boro".
. 2012-05-27 17:14:22.109 Keyboard-interactive authentication refused
. 2012-05-27 17:14:22.109 Prompt (6, SSH password, , &Password: )
. 2012-05-27 17:14:22.109 Using stored password.
. 2012-05-27 17:14:22.109 Sent password
. 2012-05-27 17:14:22.156 Access granted
. 2012-05-27 17:14:22.171 Opened channel for session
. 2012-05-27 17:14:22.203 Primary command failed; attempting fallback
. 2012-05-27 17:14:22.234 Started a shell/command
. 2012-05-27 17:14:22.234 --------------------------------------------------------------------------
. 2012-05-27 17:14:22.234 Using SCP protocol.
. 2012-05-27 17:14:22.234 Doing startup conversation with host.
. 2012-05-27 17:14:22.234 Skipping host startup message (if any).
> 2012-05-27 17:14:22.234 echo "WinSCP: this is end-of-file:0"
< 2012-05-27 17:14:22.328 WinSCP: this is end-of-file:0
. 2012-05-27 17:14:22.328 Detecting variable containing return code of last command.
. 2012-05-27 17:14:22.328 Trying "$status".
> 2012-05-27 17:14:22.328 echo "$status" ; echo "WinSCP: this is end-of-file:0"
< 2012-05-27 17:14:22.421 WinSCP: this is end-of-file:0
. 2012-05-27 17:14:22.421 Trying "$?".
> 2012-05-27 17:14:22.421 echo "$?" ; echo "WinSCP: this is end-of-file:0"
< 2012-05-27 17:14:22.515 0
< 2012-05-27 17:14:22.515 WinSCP: this is end-of-file:0
. 2012-05-27 17:14:22.515 Return code variable "$?" selected.
. 2012-05-27 17:14:22.515 Clearing all aliases.
> 2012-05-27 17:14:22.515 unalias "ls" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:22.609 -sh: line 4: unalias: ls: not found
< 2012-05-27 17:14:22.609 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:22.609 unalias "echo" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:22.703 -sh: line 5: unalias: echo: not found
< 2012-05-27 17:14:22.703 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:22.703 unalias "pwd" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:22.796 -sh: line 6: unalias: pwd: not found
< 2012-05-27 17:14:22.796 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:22.796 unalias "cd" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:22.890 -sh: line 7: unalias: cd: not found
< 2012-05-27 17:14:22.890 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:22.890 unalias "groups" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:22.984 -sh: line 8: unalias: groups: not found
< 2012-05-27 17:14:22.984 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:22.984 unalias "scp" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.078 -sh: line 9: unalias: scp: not found
< 2012-05-27 17:14:23.078 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.078 unalias "rm" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.171 -sh: line 10: unalias: rm: not found
< 2012-05-27 17:14:23.171 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.171 unalias "mv" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.312 -sh: line 11: unalias: mv: not found
< 2012-05-27 17:14:23.312 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.312 unalias "mkdir" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.406 -sh: line 12: unalias: mkdir: not found
< 2012-05-27 17:14:23.406 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.406 unalias "chmod" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.500 -sh: line 13: unalias: chmod: not found
< 2012-05-27 17:14:23.500 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.500 unalias "chgrp" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.593 -sh: line 14: unalias: chgrp: not found
< 2012-05-27 17:14:23.593 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.593 unalias "chown" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.687 -sh: line 15: unalias: chown: not found
< 2012-05-27 17:14:23.687 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.687 unalias "unset" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.781 -sh: line 16: unalias: unset: not found
< 2012-05-27 17:14:23.781 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.781 unalias "unalias" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.859 -sh: line 17: unalias: unalias: not found
< 2012-05-27 17:14:23.859 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.875 unalias "ln" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:23.953 -sh: line 18: unalias: ln: not found
< 2012-05-27 17:14:23.953 WinSCP: this is end-of-file:1
> 2012-05-27 17:14:23.968 unalias "cp" ; echo "WinSCP: this is end-of-file:$?"
! 2012-05-27 17:14:24.062 -sh: line 19: unalias: cp: not found
< 2012-05-27 17:14:24.062 WinSCP: this is end-of-file:1
. 2012-05-27 17:14:24.062 Clearing national user variables.
> 2012-05-27 17:14:24.062 unset "LANG" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.156 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.156 unset "LANGUAGE" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.250 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.250 unset "LC_CTYPE" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.343 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.343 unset "LC_COLLATE" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.437 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.437 unset "LC_MONETARY" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.531 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.531 unset "LC_NUMERIC" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.625 WinSCP: this is end-of-file:0
> 2012-05-27 17:14:24.625 unset "LC_TIME" ; echo "WinSCP: this is end-of-file:$?"
< 2012-05-27 17:14:24.718 WinSCP: this is end-of-file:0