Scheduling synchronization from Linux to Windows to Owncloud

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

 

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" "synchronize local D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup\ /home/sorin/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.

 

Summary

I use this script to synchronize 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 synchronize all files to the local folder D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup".

synchronize local D:\users\Sorin\owncloud\Software.backup\cyndane\etc.backup\ /home/sorin/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 file transfers from linux to Windows.

 

Sources

https://winscp.net/eng/docs/ui_generateurl

https://winscp.net/eng/docs/guide_schedule

https://winscp.net/eng/docs/scriptcommand_synchronize

 

 

Stop Spam Harvesters, Join Project Honey Pot

 

Get a free SSL certificate!

 

The leading nonprofit defending digital privacy, free speech, and innovation.

 

The Linux Foundation provides a neutral, trusted hub for developers and organizations to code, manage, and scale open technology projects and ecosystems.

 

Kubuntu is an operating system built by a worldwide community of developers, testers, supporters and translators.

 

 43ef5c89 CanonicalUbuntudarktext