SubscribeXMLTagsEditHistoryDiscussion

  1. Introduction
  2. Requirements
  3. Installation
  4. Modus operandi

Introduction

File-mirror is a chicken egg used to update a remote copy of a local directory. It has certain advantages and (certain distadvantages) which might make it very useful (entirely useless) for you.

Advantanges are:

Disadvantages might be:

I use it file-mirror very frequently. I like to make as little assumptions on the server as possible, to make it easy to move to different hosting providers. Here are a few examples of situations where file-mirror might be useful:

Requirements

file-mirror needs Chicken.

Installation

Download the contents of:

Run:

cd file-mirror
chicken-setup file-mirror
for module in sha1 md5 format-modular srfi-40 stream-ext; do
  chicken-setup $module;
done
make

Modus operandi

From Chicken's CSI:

(update-mirror-tar-ssh HASH SRC SERVER DST)

Here HASH is a hashing function (use mtime-hash-calc if you want to use files' timestamps to detect changes or md5-hash-calc if you want to use their MD5 hash to detect changes), SRC is the source directory in the local machine that you want to upload somewhere, SERVER is the server you want to upload things to (it could include a username, as in azul@freaks-unidos.net) and DST is the directory on the remote server where you are uploading things.

You can do this from the command line with:

ssh-tar-mirror SRC SERVER DST

This will assume you want to use the MD5 hashes (right now there is no way to specify the hash function you want to use from the command line).

file-mirror will use SRC/.file_mirror_hash to store/load the hashes (according to whatever hash function you specify) for all the files in SRC. If this is the first time it is run for SRC (which means it won't find the .file_mirror_hash file), it will simply upload all files. If, on the other hand, it manages to read it, it will compare the hashes of all the files with the values it calculated during the last update. All modified files get uploaded to the remote directory. Ah the end of the run, it will store the hashes of all files.

An obvious consequence is that if you want file-mirror to upload all files in a given directory (regardless of the state of the remote copy), it suffices to erase the SRC/.file_mirror_hash file.

file-mirror will never upload files ending with tilde (~) or beginning with a dot (.). You could change this behaviour by modifying its ignore-file? function.

You can set two environment variables:

Last update: 2007-06-18 (Rev 11686)

svnwiki $Rev: 14721 $