CryCopy - readme.txt
====================

Last updated:	11th January 2013
Author:		Brian Cryer


CryCopy is a command line utility that provides much the same functionality as Web Site Publisher. Both of these utilities share the same core "engine", the main differences are the interface and some functionality around the interface. For example Web Site Publisher manages configuration information for each "web site" that it helps maintain, but CryCopy has no concept of a "web site". This "management" information must instead by supplied on the command line.
 
The name "CryCopy" shows the original origin of the tool. It was originally intended as a backup utility and is still used in this role in several companies.
 
Run CryCopy with no arguments will show what command line flags it takes:
 
C:\>CryCopy
CryCopy <Source> <Destination> [/C] [/delete] [/D:date] [/E:Logfile]
        [/L:logfile] [/M] [/N] [/O] [/P:pass] [/R] [/S] [/U:user] [/Vn]
        [/Active] [/Passive] [/1] [+copy-spec]
        [-ignore-spec] [/T:xxx]
Flags:-
  /A:ascii-spec  Specify ASCII files (for FTP only).
  /Active  Use ACTIVE FTP (for FTP only).
  /C    Continue if an error occurs.
  /CH:xxx  Chmod new file and sub-directory setting (FTP only).
  /ChmodF:xxx  Chmod new file setting (FTP only).
  /ChmodS:xxx  Chmod new sub-directory setting (FTP only).
  /delete  Delete obsolete target files (default to keep them)
  /D:date  Only copy files modified on or after the specified date
  /E:LogFile  Error log file. Errors appended to.
  /I    Ignore errors - use with /C to allow /Delete after errors encountered
  /L:LogFile  Logfile to log to. Overwritten each time.
  /M    Make (i.e. create) target directory if it does not exist
  /N    Only copy Newer files
  /O    Do not delete destination files that predate the start date
  /P:pwd   Password. Used for ftp connections.
  /Passive  Use Passive FTP (for FTP only). Default is Passive then Active.
  /R    Overwrite Read-only files
  /S    Consider sub-directories
  /Sim  Simulate only, show what would be copied or deleted but without coping
        or deleting anything.
  /T:xxx Temporary file prefix, causes copy to temporary file first
  /U:uid   Username. Used for ftp and network connections.
  /V0   Suppress progress summary.
  /V1   More Verbose output. Lists everything that is copied or deleted
  /V2   Very Verbose output. Lists every action.
  /V:E   Verbose-Explain.
  /1    Allow a one second time drift between source and destination.
        Useful for systems that use inprecise dates such as some NAS/Unix systems.
  +copy-spec  Wildcard expression for files to copy.
  -exclude-spec  Wildcard expression for files not to copy.
  #ignore-spec  Wildcard expression for files to ignore (and not delete).
                a trailing slash ("\") indicates a directory not to copy.
  ^move-spec  Wildcard expression for files to copy and then delete locally.
              Note:
                1. The ^ character means line continuation in command files so
                   be sure to surround it in quotes.
                2. ^ implies - in that files that are moved will not be deleted
                   on the remote server.
                3. The current implementation only deletes the file if it has
                   copied it, not if the file already exists at the destination.
                   This behaviour may change.
For FTP connections use ftp://server/dir
CryCopy is produced by www.cryer.co.uk


In time I may provide a more lengthy description of each argument, but until someone asks for that I hope the following examples will suffice:

 
1. Publish a website.
 
Other than the username and password, the following is the script that was once used to update the www.cryer.co.uk website:
 
CryCopy "C:\Users\Brian\Web\Home Page" ftp:\\www.cryer.co.uk\public_html /u:myusername  /p:mypassword /v1 /subs /delete /V:Explain /Errors:C:\Temp\PubCryerErr.log
 
the following example (again other than the username and password) update a test website that I maintain:

CryCopy "c:\users\brian\web\home page" ftp:\\upload.ntlworld.com /U:username /P:password /V1 /delete /subs /errors:C:\Temp\PubNtlErr.log


2. To download from an FTP site:

The following script was used (weekly) to download virus definitions from the network associates ftp site:

CryCopy ^
 ftp:\\ftp.nai.com\pub\antivirus\datfiles\4.x  ^
 C:\Active\Virus\Defs     ^
 /user:anonymous      ^
 /V1       ^
 /Log:Update.log      ^
 /DeleteOld


3. To backup a set of files from a local folder to a network share:

CryCopy /subs /readonly /newer /Make /V1 /deleteold ^
 "C:\Brian\Other Notes" ^
 "\\kserv\Brian\Notes" ^
 -*.tmp  ^
 -*.bak  ^
 -*.wbk

This copies everything except tmp, bak and wbk files from the local folder to a network share. It does not copy sub-directories, because the "/s" flag has not been specified.


4. To copy a single specific file from one folder to another:

CryCopy "C:\Brian\Other Notes" "C:\Temp" +\file.doc

Normally "+" is used to specify a wildcard expression, such as "+*.doc". In this case there is no wildcard, so the file will only be copied if it matches against the full path. The starting directory, in this case "C:\Brian\Other Notes" is not included when performing the wildcard match, so "\file.doc" means only a file called "file.doc" in the top most folder considered, which in this case is "C:\Brian\Other Notes\file.doc".


5. To use an FTP port other than the default (control) port of 21, append :port-number to the server address. So for example, to use port 20 instead of the default port 21:

CryCopy "c:\users\brian\web\home page" ftp:\\upload.ntlworld.com:20 /U:username /P:password /V1 /delete /subs /errors:C:\Temp\PubNtlErr.log

Do not specify a port unless you have good reason for doing so, as in most cases this will stop it from working.


Note:

1. Whilst these examples are copying to an FTP site, it can be used locally to copy from drives or network shares.

2. Other than a source and destination, all other parameters are optional.
If you provide a spec of files to copy, e.g. "+*.htm", then ONLY those files that match will be copied. If you don't specify any files to include in the copy then all files will be copied.

3. The + and - file specs are matched against the full path name not just the filename, so "-*\foo\*.tmp" will ignore any tmp files under "\foo" (or \foo\example\ etc).
To specify to ignore a folder add a trailing backslash, so "-*\foo\" will ignore all directories called "foo".

4. You cannot (currently) use a trailing backslash to specify to include only matching folders.


Troubleshooting
---------------

Error:
  Trying active rather than passive.
  !! Error: Failed to connect to server kserv.
  Error code: 87
  Description: The parameter is incorrect (#87)
  Last response:
  !! Error: Failed to connect to destination ftp:\\kserv\..

check that you have specified a username (/U:).
