Topic "Automatic synchronizing"

Author Message
Hendrikdegraaf
[View user's profile]

Joined: 24 Nov 2006
Posts: 2
Location: Holland
Hello,
I have a feeling that this is a really stupid question, but I've looked for ages and I can't find wat I am looking for.

I want to create a script that does the following:
Start WinSCP
Start a stored session
Synchronize local [local docs] [docs on server]

or,

The script starts when I start WinSCP
Start a stored session
Synchronize local [local docs] [docs on server]

I hope someone can help, because I really don't get the terminal: it sais I have to work on a seperate shell. Also I don't get the scrips on the website: it seems that many of them are scripts that start other scrips, which all seems a little farfetched.

I'm looking forward to hearing from someone.

Kind regards,
Hendrik
Advertisements
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19172
Location: Prague, Czech republic
Hendrikdegraaf wrote:
I want to create a script that does the following:
Start WinSCP
Start a stored session
Synchronize local [local docs] [docs on server]

script.txt:
Code:
open stored_session
synchronize local [local docs] [docs on server]

script.bat
Code:
winscp3.exe /console /script=script.txt

_________________
Martin Prikryl
Hendrikdegraaf
[View user's profile]

Joined: 24 Nov 2006
Posts: 2
Location: Holland
It works. Thanks!
AMK

Guest


Hi,
I am using a WinSCP sync script in conjunction with Windows Task Scheduler. When a sync occurs and a new local file is identified, are the entire contents of the file added to the remote server or just the new parts. The reason I ask is the files on the local server become quite large (~100MB) and we have about 15 local files that change about once an hour. If the sync is copying the entire contents at each sync, we're going to kill our T1 line.

Can you advise on this matter?

Thanks
bdornbush
[View user's profile]

Joined: 26 Sep 2007
Posts: 1
Location: Santa Rosa, CA
I had a similar need, and after reading through the site, I arrived at this script which allows me to synchronize the files from a remote server to my local PC. I do this so that I have a copy of the most recent backups from my server to my PC.

I was delighted to find WinSCP as it allows me to do secure transfers between my server and my local PC, which I consider to be essential.

I have a directory on my server named "backups." In this directory, I have another directory, "archives" which holds the files that I want to copy. In "backups," I also have the script files to do my backups.

My script was derived from some I found on this site. At first, I planned to copy files from my server to my local PC, but then I found "synchronize" and this works better for me as it only copies the new files, that is, the most recent backups. I left the copy commands for reference. The script is:

# 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
open user@server.org
# Change remote directory
cd backups
# Force binary mode transfer
option transfer binary
# Download file to the local directory
# get archives/* f:\backups\archives\*
# Delete downloaded files
# rm archives/*
# sync from remote to local
synchronize local f:\backups\archives archives
# Exit WinSCP
exit

I used Windows XP Scheduled Tasks to run this program weekly, a few hours after the backup is generated on the server. The command I used in Scheduled Tasks is:

C:\PROGRA~1\WinSCP\WinSCP.exe /console /script=f:\backups\download.txt /log=f:\backups\winscp.txt

This command runs WinSCP and uses the script "download.txt" and logs the results to "winscp.txt" These files are on my F: drive in the backups directory.

I hope that this script is useful to others.
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19172
Location: Prague, Czech republic
AMK wrote:
I am using a WinSCP sync script in conjunction with Windows Task Scheduler. When a sync occurs and a new local file is identified, are the entire contents of the file added to the remote server or just the new parts. The reason I ask is the files on the local server become quite large (~100MB) and we have about 15 local files that change about once an hour. If the sync is copying the entire contents at each sync, we're going to kill our T1 line.

Entire file content is transferred, as there's no way for WinSCP to verify that contents of the two files matches (apart from downloading the whole file of course Smile)
_________________
Martin Prikryl
mixersoft

Guest


prikryl wrote:

script.txt:
Code:
open stored_session
synchronize local [local docs] [docs on server]



I'm trying to follow this exactly, but when I run the open command, I always get an interactive window to choose the saved session, and the script seems to die. This is what I am using:

Code:

# the script on errors
option batch on

# Disable overwrite confirmations that conflict with the previous
option confirm off

# Connect
open session_name


What am I doing wrong?[/code]
mixersoft

Guest


nevermind. I was using an old version.
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19172
Location: Prague, Czech republic
For automation please read FAQ.
_________________
Martin Prikryl
giselle

Guest


Thank u bdornbush Very Happy
AlphaUno
[View user's profile]

Joined: 13 Aug 2012
Posts: 5
Location: Nashville, TN
Hi I am wanting to create some script that will move all the files from an one of my servers to another. This is going to be used for backup purposes and run often.

I see the synchronization is the way to go and I have easily created some batch files that will do this with winscp.

However my problem lies in that I don't want all files from that folder moved only ones with the a file name that begins with "cl"

Here is my code.



Code:
open asp1_checks

pause


synchronize -filemask="cl.*" local "Y:\checks\" "/asp1/luminx/naa/live/jacob/checks/"

exit
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19172
Location: Prague, Czech republic
AlphaUno wrote:
However my problem lies in that I don't want all files from that folder moved only ones with the a file name that begins with "cl"

...
Code:
open asp1_checks

pause


synchronize -filemask="cl.*" local "Y:\checks\" "/asp1/luminx/naa/live/jacob/checks/"

exit

Duplicate post:
http://winscp.net/forum/viewtopic.php?t=11712
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License