@echo off
REM This script backups local source file to remote timestamped target file.
REM Please change the variables in step (1) first before running the script.

REM (0) set up timestamp string
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "ISO_TIMESTAMP=%YYYY%-%MM%-%DD%T%HH%:%Min%:%Sec%"

REM (1) set up all backup varables
set JAVA_HOME=\path\to\JavaHome
set COMMANDER_HOME=\path\to\crossftp-all-bin
set SOURCE_FILE_PATH=\path\to\source\file
set TARGET_SITE_ID=ID
set TARGET_FILE_PATH=/path/to/target/file.%ISO_TIMESTAMP%

REM (2) start backup
echo Backup %SOURCE_FILE_PATH% to remote file %TARGET_FILE_PATH%

START /D %COMMANDER_HOME% /B /WAIT commander.bat --action copy --sourceSite MyComputer --sourceFile %SOURCE_FILE_PATH% --targetSite %TARGET_SITE_ID% --targetFile %TARGET_FILE_PATH%

REM (3) show user the result
echo Finished backup %SOURCE_FILE_PATH% to remote file %TARGET_FILE_PATH%
