This website stores cookies. Click here to accept them.cookie information page

File synchronisation using winscp

10th February 2012
Categories: backups, winscp

If you're responsible for maintaining a heap of files or databases and making sure you don't lose all trace of them when your server goes down, or you just want to make sure that your desktop PC is or laptop is backed up regularly, there are a few ways to go. 

If you need version control, there are applications like 'Subversion' which are designed for managing code, but can manage any type of file and give you a full version history.  You have to commit changes manually, but using "Tortoise SVN" gives you a red cross against any files you haven't yet committed.  If you don't want to set up your own Subversion server, companies like Codesion make it easy for you.

If what you really want is continuous backup, you should be looking at services like Dropbox or Mozy. These companies give you a small program to install on your computer which handles backups continuually; with dropbox it manages one folder; with other services you can specify multiple. Dropbox, however, gives you 2GB free to play with at the start.

However, if you have your own FTP or SFTP site and you don't need version control or continuous backup, WinSCP offers a little-known but free of charge solution.  

WinSCP is a file transfer program, but it comes with a powerful scripting language, including commands like synchronize (full list here).

You can run winscp on a command line and tell it to go and execute a script (which means that you can schedule said command using the Windows scheduler)

Your script can be as simple as this:

open serverBob
synchronize local C:\Backups\bob /home/bob/myfolder

(which opens a saved, named session (use the normal WinSCP window to set this up first), and copies remote files to your hard disk)

or this:

open serverBob
synchronize remote C:\Backups\bob /home/bob/myfolder

(which does the reverse).

Save your scripts as text files, and to call your scripts, just run winscp.exe /script=yourscript.txt (where yourscript.txt is the path to your script).

Happy copying!

[Edit, 14 May]

I just got caught out by the following: if you give your scheduled tasks your own user name and password, you may forget to change the scheduled tasks' login credentials when you change your own password.  Far better to give the scheduled tasks their own dedicated windows user and password!


Add your comment for "File synchronisation using winscp":

© Alberon Ltd 2019

8 Standingford House
26 Cave Street

01865 596 144

Oxford Web is a trading name of Alberon Ltd, registered company no. 5765707 (England & Wales).