Synchronisation scripting headache
I've been trying to get a script for synchronising working over the last few days and its proving a huge headache. It just doesn't seem to work as expected.
I'm synchronising a directory where there is multiple subdirectories. I only want some of these subdirectories so I'm using either option include or exclude.
Here's the script using option exclude;
============
option confirm off
open sftp://budgetscp:<passwd>@<ip>
cd /www_backup/OpenJaw
option exclude "E:\budget\Copy of tomcat\"
option exclude "E:\budget\tomcat\logs\*"
option transfer binary
synchronize remote -criteria=both E:\budget\
close
exit
=============
And its output;
=============
E:\budget>winscp.com /command /script=ftp.txt
batch on
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "budgetscp".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] budgetscp@<ip>
/www_backup/OpenJaw
exclude E:\budget\Copy of tomcat\
exclude E:\budget\tomcat\logs\*
transfer binary
Comparing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
Synchronizing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
E:\budget\Copy of tomcat | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\Copy of tomcat\bin | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\bin\bootstrap.jar | 23 KiB | 1246.4 KiB/s | binary | 100%
E:\...\bin\catalina.bat | 7 KiB | 134.1 KiB/s | binary | 100%
E:\...\bin\catalina.sh | 9 KiB | 87.3 KiB/s | binary | 100%
E:\...\commons-daemon.jar | 9 KiB | 75.8 KiB/s | binary | 100%
E:\...\bin\cpappend.bat | 0 KiB | 53.3 KiB/s | binary | 100%
E:\...\bin\digest.bat | 1 KiB | 34.1 KiB/s | binary | 100%
E:\...\bin\digest.sh | 0 KiB | 25.8 KiB/s | binary | 100%
E:\...\bin\jasper.bat | 2 KiB | 21.1 KiB/s | binary | 100%
E:\...\bin\jasper.sh | 0 KiB | 18.8 KiB/s | binary | 0%
Terminated by user.
===========
As you can see its including the directory I told it to exclude. I've used lots of different combinations in the exclude;
E:\budget\web\Copy of tomcat*
E:\budget\web\Copy of tomcat\
E:\budget\web\Copy of tomcat\*
E:\budget\web\Copy of tomcat\*.*
The "Copy of tomcat" directory is still included no matter what.
I've also tried using the option include method, with slightly more success, but only slightly. Here's the script;
============
option confirm off
open sftp://budgetscp:<passwd>@<ip>
cd /www_backup/OpenJaw
option include "E:\budget\web\"
option transfer binary
synchronize remote -criteria=both E:\budget\
close
exit
=============
And here's the output;
=============
E:\budget>winscp.com /command /script=ftp.txt
batch on
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "budgetscp".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] budgetscp@<IP>
/www_backup/OpenJaw
include E:\budget\web\
transfer binary
Comparing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
Synchronizing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
E:\budget\web | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\book.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\book.jsp_new | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\brochureSearch.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\config | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\css | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\error.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\home.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\images | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\index.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\old | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\packageResults.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\packageSearch.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\pages | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\popups | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\scripts | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\SessionAdmin.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\waitForResults.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\WEB-INF | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\xRezError.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\xRezReset.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
Session 'budgetscp@193.95.150.26' closed.
No session.
============
This files should not be 0 KB and nothing shows up on the remote server except for the "web" subdirectory which is empty.
Is there any chance somebody could help me out here because I'm not sure of the syntax for the option commands? Shoud I be using windows directory notation or unix?
Some further examples of those would be helpful in the documentation, like having multiple "option exclude <dir>" in a row, or how the include/exclude pipe works mentioned on the last line of the File Mask section.
Thanks for any help,
R
I'm synchronising a directory where there is multiple subdirectories. I only want some of these subdirectories so I'm using either option include or exclude.
Here's the script using option exclude;
============
option confirm off
open sftp://budgetscp:<passwd>@<ip>
cd /www_backup/OpenJaw
option exclude "E:\budget\Copy of tomcat\"
option exclude "E:\budget\tomcat\logs\*"
option transfer binary
synchronize remote -criteria=both E:\budget\
close
exit
=============
And its output;
=============
E:\budget>winscp.com /command /script=ftp.txt
batch on
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "budgetscp".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] budgetscp@<ip>
/www_backup/OpenJaw
exclude E:\budget\Copy of tomcat\
exclude E:\budget\tomcat\logs\*
transfer binary
Comparing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
Synchronizing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
E:\budget\Copy of tomcat | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\Copy of tomcat\bin | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\bin\bootstrap.jar | 23 KiB | 1246.4 KiB/s | binary | 100%
E:\...\bin\catalina.bat | 7 KiB | 134.1 KiB/s | binary | 100%
E:\...\bin\catalina.sh | 9 KiB | 87.3 KiB/s | binary | 100%
E:\...\commons-daemon.jar | 9 KiB | 75.8 KiB/s | binary | 100%
E:\...\bin\cpappend.bat | 0 KiB | 53.3 KiB/s | binary | 100%
E:\...\bin\digest.bat | 1 KiB | 34.1 KiB/s | binary | 100%
E:\...\bin\digest.sh | 0 KiB | 25.8 KiB/s | binary | 100%
E:\...\bin\jasper.bat | 2 KiB | 21.1 KiB/s | binary | 100%
E:\...\bin\jasper.sh | 0 KiB | 18.8 KiB/s | binary | 0%
Terminated by user.
===========
As you can see its including the directory I told it to exclude. I've used lots of different combinations in the exclude;
E:\budget\web\Copy of tomcat*
E:\budget\web\Copy of tomcat\
E:\budget\web\Copy of tomcat\*
E:\budget\web\Copy of tomcat\*.*
The "Copy of tomcat" directory is still included no matter what.
I've also tried using the option include method, with slightly more success, but only slightly. Here's the script;
============
option confirm off
open sftp://budgetscp:<passwd>@<ip>
cd /www_backup/OpenJaw
option include "E:\budget\web\"
option transfer binary
synchronize remote -criteria=both E:\budget\
close
exit
=============
And here's the output;
=============
E:\budget>winscp.com /command /script=ftp.txt
batch on
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "budgetscp".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] budgetscp@<IP>
/www_backup/OpenJaw
include E:\budget\web\
transfer binary
Comparing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
Synchronizing...
Local 'E:\budget' => Remote '/www_backup/OpenJaw'
E:\budget\web | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\book.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\book.jsp_new | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\brochureSearch.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\config | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\css | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\error.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\home.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\images | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\index.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\old | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\packageResults.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\packageSearch.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\pages | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\popups | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\scripts | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\SessionAdmin.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\waitForResults.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\budget\web\WEB-INF | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\xRezError.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
E:\...\web\xRezReset.jsp | 0 KiB | 0.0 KiB/s | binary | 0%
Session 'budgetscp@193.95.150.26' closed.
No session.
============
This files should not be 0 KB and nothing shows up on the remote server except for the "web" subdirectory which is empty.
Is there any chance somebody could help me out here because I'm not sure of the syntax for the option commands? Shoud I be using windows directory notation or unix?
Some further examples of those would be helpful in the documentation, like having multiple "option exclude <dir>" in a row, or how the include/exclude pipe works mentioned on the last line of the File Mask section.
Thanks for any help,
R
Last edited by rclerkin on 2009-07-20 11:15; edited 1 time in total