ftp2svn

Small bash script for mirroring websites via FTP and archiving the mirror in subversion.

This is a bash script for backing up any collection of files over FTP and saving the mirror to a Subversion repository.

A diagram of how the script can be used is here.

We also combine this with the WordPress database backup plugin to backup and track WordPress sites.

Usage and examples

sudo apt-get install subversion lftp libxml-xpath-perl

Dependencies

Make sure that you can install Subversion, LFTP and xpath in your command line, this script will use them all at some point. This example is for Ubuntu users.

chmod u+x ftp2svn.sh

Setup

Grab the ftp2svn.sh file and save it somewhere nice in your folders. This code assumes that you've added it to your path.

You must allow the script to be executed. You can do that with this line.

ftp2svn
cd ~/.ftp2svn
mv site.conf.example yoursite.site.conf
vi yoursite.site.conf

Configuration

Perform the first execution of the script, this will build the ~/.ftp2svn config folder.

Now drop in to that folder and edit the example config file.

ftp2svn --build

Building

Run the script with the '--build' flag. ftp2svn will test your settings, build initial repositories and create the lftp command files for each site if the FTP credentials give it access to the folder specified in the settings.

You can now add ftp2svn to your crontab to run regularly.