Home » Tips & Tricks » MS Windows » Windows folder sync to remote folder on linux

Windows folder sync to remote folder on linux

I always confess my love of Linux. All I need is some rsync and ssh and there’s nothing I can’t do.

My wife runs Windows 7 and maintains our finances, so backups are important. I tried all the normal stuff like Robocopy and SyncToy, but both would do strange things when added to Taskscheduler.

 I’m sure they work fine and I might have neglected to check the box for “Wake up computer to perform this task” and the other box for “only run tasks if this network connection is active“, but, hey, I’m not a Windows guy and only now noticed those check boxes while typing this post.

 I did realize that you can use WinSCP in a command line and scripted mode. This makes me happy because it’s SCP which is part of ♥SSH♥

So I created some directories

  • c:sync
  • c:syncscripts
  • c:synclogs

In this scenario I am syncing c:John to the folder /RAID/pub/User_Files/John on my linux server 192.168.1.254.

Then I fired up Notepad and created a script file. I called it sync.txt (points for originality here!)

# This is C:syncscriptssync.txt

# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect, this must be setup in WinSCP as a saved session and have password saved
open user@192.168.1.254
# Change remote directory where your folder is.
# My folder is /RAID/pub/User_Files/John
cd /RAID/pub/User_Files
# Force binary mode transfer
option transfer binary
# Download file to the local directory
# get archives/* f:backupsarchives*
# Delete downloaded files
# rm archives/*

# The line below would sync from remote to local
# synchronize local f:backupsarchives archives
#
syncing local to remote while deleting removed files
synchronize remote -delete c:John John
# Exit WinSCP
exit

Then I used this command in Task-scheduler:
c:”Program Files (86)”WinSCPWinSCP.exe /console /script=c:syncscriptssync.txt /log=c:synclogswinscp.txt


Actually it I selected “Run Program” then browsed to c:”Program Files (86)”WinSCPWinSCP.exe, Then in the  arguments box  I added /console /script=c:syncscriptssync.txt /log=c:synclogswinscp.txt


Also keep in mind to check the boxes for “Wake up computer to perform this task” and the other box for “only run tasks if this network connection is active” (while selecting your active wifi or network link)

Was this helpful?
If you found my posts interesting, or I helped you figure something out, please consider tossing me a tiny gratuity for my time, research, to help offset the web hosting/development costs or to buy me a cup of coffee.

* This post may contain affiliate links. This means that I “might” receive a tiny amount of money, if you make a purchase using one of our links. It does not cost you anything extra, and helps us defray the costs of hosting and maintaining this site.

Leave a Reply