1. Scheduling file transfers from Linux to Windows to Owncloud

This is somewhat convoluted, but works, and also offers a backup of sorts as a bonus.


2. The steps

  1. Download and install WinSCP on your Windows computer.

  2. Create a site account to your linux computer in WinSCP. Save the password.

  3. Login to the linux site.

  4. Click on the file or folder you want to schedule a transfer for.

  5. Click menu Files/File names/Generate file URL.
    1. Check User name, SSH host key and Password.
    2. Click Close or Copy to clipboard as appropriate.
    3. I recommend opening a new Notepad++ session and pasting the generated URL there. Save it!

  6. Click menu Session/Generate session URL/code.
    1. On the URL tab check User name, SSH host key, Password and Initial directory.
    2. On the Script tab choose format Command-line.
    3. Click Copy to clipboard.
    4. Paste it to the same file opened in 5.2. Save it!

  7. You should now have two lines in Notepad++.
    1. Combine them so they look something like the below. You should have one line, possibly word-wrapped.
      "C:\Program Files (x86)\WinSCP\winscp.exe" /log="D:\users\Sorin\owncloud\Software.backup\cyndane\WinSCP.log" /ini=nul /command "open sftp://YOURUID:This email address is being protected from spambots. You need JavaScript enabled to view it.:22/home/sorin/etc.backup/ -hostkey=""ssh-rsa 2048 keykeykeykeykeykeykeykey"" -rawsettings PingType=1 Compression=1 ProxyPort=0" "get * D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup\" "exit"
    2. Save the file.
    3. Add or change the file extension to eg .bat as neccessary.

  8. Open a Command prompt in Windows.

  9. Change directory to wherever you saved the file from 7.2.

  10. Do a test run. If it worked, go to 11. Else review your command and correct as neccessary.

  11. Create a scheduled task in Windows to run the transfer. See https://winscp.net/eng/docs/guide_schedule for more info.


3. Summary

I use this script to transfer any files from various folders on one of my Linux servers. I further make use of my Owncloud linux server and the Owncloud Windows desktop sync client to sync the tars and have them in more than one place, thus effectively having an off-site backup copy.

The command in 7.1 basically means "from the folder /home/sorin/etc.backup transfer all files to the local folder D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup".

get * D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup\

The folder D:\users\Sorin\owncloud and its sub-folders is then synced to the Owncloud server using the Owncloud Desktop Sync Client.


Also see the article Scheduling synchronizations from linux to Windows.


4. Sources