With 3 easy steps, using WinSCP and SmartFile, you can sync important folders and files from a Windows 2008 Server to SmartFile. Using task scheduler, this can be automated on a nightly basis with a log file that’s generated each evening.
This is useful for a number of obvious reasons, like logging, file backup and compliance.
1) Download WinSCP
2) Create a winscp_sync.txt file
Add the following information to a file named winscp_sync.txt (ssh-keys can be used instead of username:password).
#errors without confirm
option batch continue
option confirm off
open sftp://username:email@example.com -hostkey="ssh-rsa 1024 64:a1:c0:90:ee:88:fe:4a:3d:bf:c3:47:a4:ee:c5:1f"
#binary mode transfer
option transfer binary
synchronize remote -delete -criteria=none -nopreservetime -nopermissions source_path /destination_path
- Here’s what you need to know about this file and its contents:
- username:password – Your SmartFile username and password
- source_path – File and folders to be backed-up to SmartFile
- /destination_path – Folder path on SmartFile system to place files and folders
3) Add a new scheduled task in Windows
Next we’re going to create a new schedule task. You’ll use the following settings:
- Under Create a new action, select “Start a program”
- Under Program/script, enter:
- Under Add arguments (optional), enter:
/c start "" path_to_winscp.exe /console /script=path_to_winscp_sync.txt /log=path_to_winscp_logs\%date:~10,4%%date:~4,2%%date:~7,2%.txt /loglevel=0
- Here’s what you need to know about the scheduled task:
- path_to_winscp.exe – Path to WinSCP.exe file
- path_to_winscp_sync.txt – Path to winscp_sync.txt file created above
- path_to_winscp_logs – Path to folder where to store daily logs
- After the start command – The empty double quote is required
This task will open a console, that then starts WinSCP.exe. Doing it this way allows us to set the date variable for the log file names.
Once this task is created, manually run it to test that all files and folders get uploaded from the source location to the destination location. Any files added or removed in the source will be reflected in the destination path. The logging provides a significant amount of info for troubleshooting.
Other Notes –
1) Be sure to set the job to “run whether user is logged on or not”.
2) Items deleted locally will be deleted remotely, remove the -delete option to NOT remove the remote items.