russischer Abakus Informatik-Vollmer
    

Manual Page of ftpsync

NAME

ftpsync - Sync a hierarchy of local files with a remote FTP repository

(Extended version)

SYNOPSIS

ftpsync [-h] [-c] [-v] [-d] [-k] [-P] [-s server] [-u username] [-p password] [-r remote] [-l local] [-i ignore] [-I ignore] [-o offset] [-R src=dst,src=dst... ]

ARGUMENTS

The recognized flags are described below:

-h
Produce this documentation.
-c
During fetching the file list from the remote system a moving | is shown for each fetched file name. After finishing the transmission a summary count of copied and deleted files and directoy is emitted.
-v
Produce verbose messages while running.
-d
Put the Net::FTP object in debug mode and also emit some debugging information about what's being done.
-k
Just kidding. Only announce what would be done but make no change in neither local nor remote files. created =item -P

Set passive mode.

-i ignore
Specifies a regexp. Remote files matching this regexp will be left alone. If no -I ignore is given, also local files matching this regexp will be left alone.
-I ignore
Specifies a regexp. Local files matching this regexp will be left alone.
-s server
Specify the FTP server to use. Defaults to localhost.
-u username
Specify the username. Defaults to 'anonymous'.
-p password
Password used for connection. Defaults to an anonymous pseudo-email address.
-r remote
Specifies the remote directory to match against the local directory.
-l local
Specifies the local directory to match against the remote directory.
-o offset
Allows the specification of a time offset between the FTP server and the local host. This makes it easier to correct time skew or differences in time zones.
-R src1=dest1,src2=dst2,...
Copy the local file src to the remote system and rename it to dest.

Several source / destinations pairs may be given an should be separated by a comma.

If there are local files foo/a and bar/a, giving the option -Ra=b specifies to copy the local foo/a to the remote file foo/b as well as bar/a is copied to the remote file bar/b. If you want only foo/a to be renamed, use: -Rfoo/a=foo/b.

This may be used e.g. to copy a .htaccess file from the local site, where it's ``disabled'' (by naming it htaccess, i.e. without the leading dot on the local site) and ``enable'' it by copying it as .htaccess to the remote site. Doing so, your local copy of the web pages may be seen without any access restriction, while on the remote site, the user must provide a password (see the specifications of .htaccess of your web server).

DESCRIPTION

This is an example script that should be usable as is for simple website maintenance. It synchronizes a hierarchy of local files / directories with a subtree of an FTP server.

The synchronyzation is quite simplistic (it uses time stamps and file size comparision). It was written to explain how to use Net::FTP and File::Find.

Always use the -k option before using it in production, to avoid data loss.

Synchronyzation means:

* If a local file is newer or differs in size, then put it to the remote site.
* If a file exists only on the local site, then put it to the remote site.
* If the file exists only on the remote site, delete it from the remote site.
* Remote files are stored in the same directory hierarchy as the local files.
* Create remote directories as needed.
* Delete remote directories if they are not existent locally.

EXAMPLE

   ftpsync -c -s my.ftp -u lem -p 37337 \
        -l /my/local/site -i '\bRCS\b|\bCVS\b|(^\.)|/\.|(~$)' -v -o 14400 \
        -R htaccess=.htaccess,htpasswd=.htpasswd

The regexp I feed to -i should prevent any CVS control files, which begins with a dot, as well as all RCS files, and any Emacs backups from being touched at all. I also specify an offset of 14,400 seconds (4 hours) to compensate for the fact that this FTP server is running in my local time zone instead of in UTC, as it should be. The -R flag specifies that htaccess files are copied as files .htaccess

BUGS

The synchronization is not quite complete. This script does not deal with symbolic links. Many cases are not handled to keep the code short and understandable.

REQUIREMENTS

Perl(1) and the perl modules Net::FTP, File::Find, Pod::Usage.

AUTHORS

The original script was written by Luis E. Muñoz <luismunoz@cpan.org>

It was extended by Dr. Jürgen Vollmer <juergen.vollmer@informatik-vollmer.de>, who added

  - the -R switch (rename)
  - the -I switch and modified -i
  - the -c switch
  - a check for file-sizes

HOMEPAGE

Homepage of the original version of ftpsync:

http://mipagina.cantv.net/lem/perl/ftpsync Its documentation may be found at http://www.linuxjournal.com/article.php?sid=6686

Homepage of this version of ftpsync:

http://www.informatik-vollmer.de/software/ftpsync.html

If you find this software useful, I (Juergen Vollmer) would be glad to receive a postcard from you, showing the place where you're living:

Dr. Juergen Vollmer, Viktoriastrasse 15, D-76133 Karlsruhe, Germany.

LICENSE

This code can be used under the same terms as Perl itself. It comes with absolutely NO WARRANTY.

Use at your own risk.

VERSION

2.0 of 2005/01/25

SEE ALSO

Perl(1).

Dr. Jürgen Vollmer (www.informatik-vollmer.de)
Diese Seite wurde am 09. März 2012 aktualisiert