Topic "Automatic synchronizing"

Author Message
Hendrikdegraaf
[View user's profile]

Joined: 2006-11-24
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
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: 2006-11-24
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: 2007-09-26
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
For automation please read FAQ.
_________________
Martin Prikryl
giselle

Guest


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

Joined: 2012-08-13
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
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
Guest




YIKES. I butchered that. Let me try again:

I've tried many different example scripts and none of them seem to work for me. Can someone help me troubleshoot?

The most recent attempt, straight from the example scripts:

bat:

Code:
winscp.com /script=script.txt /parameter // %1 "/internet/remotedirectory/%~n1%~x1"


txt:

Code:
# Being intended for interactive session, we are not enabling batch mode
# Connect
open sftp://user:pword@sftp.address.gov -hostkey="ssh-rsa 1024 9c:b7:21:5c:ad:02:bb:30:c5:27:a5:bc:41:1a:ab:a0"
# Synchronize paths provided via environment variables
synchronize remote "%1%" "%2%"


I run this bat file and the window closes at: Authenticating with pre-entered password.

What I really want to do is synchronize the local folder to the remote folder, but for the sake of learning, I'm just trying to get any script working.

Previously, I had tried:

Code:
option batch abort
option confirm off
open sftp://user:pword@sftp.address.gov -hostkey="ssh-rsa 1024 9c:b7:21:5c:ad:02:bb:30:c5:27:a5:bc:41:1a:ab:a0"
synchronize local H:\LocalDirectory /internet/remotedirectory
exit
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
Anonymous wrote:
I've tried many different example scripts and none of them seem to work for me. Can someone help me troubleshoot?

The most recent attempt, straight from the example scripts:

bat:

Code:
winscp.com /script=script.txt /parameter // %1 "/internet/remotedirectory/%~n1%~x1"

...


Your duplicate post on superuser.com:
http://stackoverflow.com/q/33680432/850848

The same answer:
Your script is generally correct. But we need to see a log file to help you. Add /log=c:\path\winscp.log to command-line.
MCG

Guest


I have connected my ftp server and my aim is to get my camera records from there to my desktop.
I have already thicked Passive Mode.

When I tried to access my records in there, I got this error on my screen.
"
Error Listing Directory "X"
Could not retrieve directory listing
Invalid path specified"
"

By the way, when I clicked on the file and push the "Calculate" button it shows that there are X files and they hold X size in disk.

When I examined the permission options, all of them are not thicked initially. When I wanted to change them it also gave this error.
"Cannot change properties of file. Unknown command SITE"

Another interesting this is that I have already accessed all of my files with Filezilla.

Do you have any solution for this problem ?

Thanks a lot.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
Again, log file please.
MCG

Guest


prikryl wrote:
Again, log file please.


CWD /110/
250 CWD command successful.
PWD
257 "/110/"
TYPE A
200 Type A Accepted
PASV
227 Entering Passive Mode (x,x,x,x,27,89) ..
LOST
Connecting to x.x.x.x:7000
125 Connected, Starting Data Transfer..
<Empty Directory Listing>
550 Invalid path specified
Could not retrieve directory listing

(ECommand) Error listing directory "110".
Could not retrieve directory listing
Invalid path specified.

This is the log file.

It says its invalid path but i have already accessed this path from filezilla.

Thanks for reply.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
No this is not a log file.

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

A log file from FileZilla would be helpful too.
bmwlover

Guest


Hi,

I have video files in one server which is ftp server.
I have already list directories and video files using winscp script. These video files seems that have no file extension. When I got the video files list, I saw that "name" there is no file extension like .mpeg or whatever it is.

I tried to get this file and I wrote this code:
get /myDirectory/myVideoFile and it said to me this file/folder is not found
get /myDirectory/myVideoFile.* and it also said to me this file is not found.
* shows that i tried all possible video file extension.

Do you have any idea to solve this problem ?

Thanks.
bmwlover

Guest


bmwlover wrote:
Hi,

I have video files in one server which is ftp server.
I have already list directories and video files using winscp script. These video files seems that have no file extension. When I got the video files list, I saw that "name" there is no file extension like .mpeg or whatever it is.

I tried to get this file and I wrote this code:
get /myDirectory/myVideoFile and it said to me this file/folder is not found
get /myDirectory/myVideoFile.* and it also said to me this file is not found.
* shows that i tried all possible video file extension.

Do you have any idea to solve this problem ?

Thanks.


Also this is my log file FYI.
mylog.log (9.12 KB) Private file

Description: myLogFile

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
bmwlover wrote:
I have video files in one server which is ftp server.
I have already list directories and video files using winscp script. These video files seems that have no file extension. When I got the video files list, I saw that "name" there is no file extension like .mpeg or whatever it is.

I tried to get this file and I wrote this code:
get /myDirectory/myVideoFile and it said to me this file/folder is not found
get /myDirectory/myVideoFile.* and it also said to me this file is not found.
* shows that i tried all possible video file extension.

Your code looks ok. Can you download the file anyhow? In GUI? Or in other FTP client?
bmwlover

Guest


prikryl wrote:
bmwlover wrote:
I have video files in one server which is ftp server.
I have already list directories and video files using winscp script. These video files seems that have no file extension. When I got the video files list, I saw that "name" there is no file extension like .mpeg or whatever it is.

I tried to get this file and I wrote this code:
get /myDirectory/myVideoFile and it said to me this file/folder is not found
get /myDirectory/myVideoFile.* and it also said to me this file is not found.
* shows that i tried all possible video file extension.

Your code looks ok. Can you download the file anyhow? In GUI? Or in other FTP client?


Yes.

I can download this file from Filezilla obviously and also can play and download in GUI.
I don't know what is going wrong.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24056
Location: Prague, Czech republic
bmwlover wrote:
I can download this file from Filezilla obviously and also can play and download in GUI.
I don't know what is going wrong.

So show us a log from the GUI please.
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