ftpmirror : mirrors a local drive onto a web site via FTP.

Download Files

Changes

  1. Initial Version

Installation

  1. copy jarrizza.jar into directory ant\lib
  2. add the following line to your build.xml
  3. <taskdef name="ftpmirror" classname="com.arrizza.ant.taskdefs.FtpMirror"/>
  4. or add the line from the defaults.properties file and recompile ant

Notes

This is a new Taskdef for Ant. It mirrors a local directory tree to a web site using FTP.

Use

The files and directories are mirrored according to these rules: >
Local Remote Action
file exists file exists check date & overwrite remote file if necessary
file exists dir exists delete remote directory tree; send local file to remote
dir exists file exists delete remote file; create remote directory
dir exists dir exists no action
file exists -- send local file to remote
dir exists -- create remote directory
-- file exists delete remote file
-- dir exists delete remote directory tree
(Please note that the when a directory is found to be extraneous on the remote site, the entire directory tree is deleted. Please be careful! Use an <exclude/> if you do not want this to occur.)

Here's the simplest target:

  <!--  ==================================== -->
  <property name="root.local"  value="d:/web/domain"/>
  <property name="root.remote" value="domain"/>

  <!--  ==================================== -->
  <target name="web">
    <ftpmirror server="${url}" userid="${uid}" password="${pwd}" >
      <local  dir="${root.local}/html"  />
      <remote dir="${root.remote}/html" />
    </ftpmirror>
  </target>

This build.xml target would do the following:

  1. establish a connection to the ftp server at ${url}
  2. the local directory tree has its root at d:\web\domain\html
  3. the remote directory tree has its root at ~/domain/html

Here's a sample with a remote exclusion:

  <!--  ==================================== -->
  <target name="web">
    <ftpmirror server="${url}" userid="${uid}" password="${pwd}" >
      <local  dir="${root.local}/html" />
      <remote dir="${root.remote}/html" >
         <exclude name="stats/"/>
      </remote>
    </ftpmirror>
  </target>

This target indicates the ~/domain/html/stats directory is to be ignored in all processing.

Here's a little more complicated sample:

  <!--  ==================================== -->
  <target name="web">
    <ftpmirror server="${url}" userid="${uid}" password="${pwd}" >
      <local  dir="${root.local}" >
         <include name="."/>
         <include name="html/"/>
         <include name="cgi-bin/"/>
      </local>
      <remote dir="${root.remote}" >
         <include name="."/>
         <include name="html/"/>
         <include name="cgi-bin/"/>
         <exclude name="stats/"/>
         <exclude name="html/logs/"/>
         <exclude name="cgi-bin/access.db" />
         <exclude name="cgi-bin/auth/" />
      </remote>
    </ftpmirror>
  </target>

This sample shows that in the local current directory there are two directories that will be included in the transfer: html and cgi-bin. The trailing '/' causes the entire directory tree to be included. Note there may be other files and sub-directories in the ${root.local} but they are not included therefore excluded from the processing.

The same subdirectories html and cgi-bin are included in the remote tree. But there is a stats subdirectory that is excluded. Also there is a logs subdirectory in the html directory treee that is to be excluded. In cgi-bin there is a file access.db to be excluded and a subdirectory auth as well.




Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001,2002,2003,2004,2005,2006,2007