nfsbu - Perl script backup system for NFS

Download:

The latest version (and so far the only) is 0.0.1, created August 2000.
by http by ftp

Info & Installation:

(Copy of the README file, sorry about the lack of wrapping)

nfsbu - NFS backup system
(C) 2000 Simon McCorkindale
v0.0.1 - 23rd August 2000

INTRODUCTION:
==============

The basic function nfsbu is an automated perl-script backup system between an NFS server and an NFS client.
Either by crontab or manual execution, directories listed in the configuration file can be backed up to a directory mounted on the NFS server. In turn, the NFS server uses the client-side script of nsbu (nfsbuc.pl) to move the data from the temporary NFS mount directory to their final places (also specified in the configuration file).

Key features include:
	- multiple directory backup, with alternative destination directories
	- directories are simply listed in a file with their respective destinations
	- thorough error checking, if any errors occur e-mail will be sent to the administrator
	- checks the status of the NFS server and mountd to prevent any hang-ups from a dead NFS server which is common

I created this script having been learning Perl for maybe 2 weeks and progressing not much further than page 12 of Programming Perl by Larry Wall and Randal L. Shwartz. Hence you may consider the code badly written, but a quote from the book I'd like to include is "a Perl script is correct if it's halfway readable and gets the job done before your boss fires you". So I take no blame for the code, I've commented my code and it worked for me and I make no promises it will work for you.

With regards to licencing, I guess its not really worthy of the full 9 yards, but lets have the happy code hacker ethic of open source development. I.e. something of somewhat basic GPL licence terms and conditions. You may feel inclined to modify the code, in such case if you do, please  e-mail me the changes and include the modified code. If you'd like to redistribute it with your modifications, please include my name and the original code.

INSTALLATION & CONFIGURATION:
==============================

This takes for granted you understand how NFS works and already have it setup.
There are 2 perl-scripts which are:

nfsbus.pl - the server-side script (located on the NFS _client_ machine/the machine where the files to be backed up reside)
nfsbuc.pl - the client-side script (located on the NFS _server_/the machine where the backed up data will be stored)

The other 2 files are:

/etc/nfsbu.conf - located on the NFS client machine. Contains the directories to be backed up and their respective target desintations on the remote machine.
.destinations - located on the the NFS server in the NFS mount directory (refer to /etc/exports). Contains the copied directories in the temporary directory (ie the NFS mounted directory) and their final destination paths on the NFS server.

** NOTE ** the directories that are backed up will always have the same name, so you'll notice I've emphasised the word PARENT destination directory several times to prevent any problems where you'll get the directory being placed as a sub-directory under the same name.
That is /usr/local/pgsql/data/data instead of /usr/local/pgsql/data. Please watch for this.

1. nfsbus.pl and /etc/nfsbu.conf:

a) The perl-script can reside anywhere you wish, maybe ideally in one of the bin directories. The arguments to run this file are:

	nfsbus.pl	<host IP> <remote directory to mount> <administrator's e-mail>

<host IP> is the IP/hostname of the NFS server (ie the machine where the data will be backed up to).

<directory to mount> is the remote directory specified in the /etc/exports file to allow NFS mounts by the authorised hosts. This is the temporary directory where the data will initially be copied to.

<administrator's e-mail> the address of the administrator in charge of the system, will e-mail on any errors when processing the backup.

b) the /etc/nfsbu.conf file should be in the following format (please refer to the example configuration file included in the archive):
If only the source directory is entered, then the destination directory is assumed to be identical.
# are allowed at the start of a line to add a comment out a line.

/source/directory /path/to/PARENT/directory/on/remote/machine

2. nfsbuc.pl:

This should be run after nfsbus.pl has finished copying the backup-data to the temporary NFS mount directory. Arguments are:

	nfsbuc.pl  <local path to NFS mount dir> <administrator's e-mail>

<local path to NFS mount dir> is the same as the specified 'remote directory to mount' argument for nfsbus.pl. This is where the data is copied too and also the location of .destinations

.destinations is the file automatically created by nfsbus.pl after copying the data. It has a list of the directories in the NFS mount dir and next to it on the same line is the path to the PARENT directory where the backup directories will be copied to, ie their final destination on the backup server.

EXAMPLE LAYOUT:
================

www.mainserver.com [Apache Web server and PostgreSQL database server]:

This is the main server for which work is done on say a day-to-day basis, where the database is updated and web pages are modified.

1. crontab is set to automatically run:

/usr/local/bin/nfsbus.pl www.backupserver.com /var/nfstemp admin@mainserver.com

every day at 7am.

2. /etc/nfsbu.conf has the following contents:

/home/httpd/docs	/home/backup
/usr/local/pgsql/data

These are the directories that will be backed up.
The "docs" directory will be copied to a different location to the PARENT path of /home/backup/.
Because the next entry has only one directory, it assumes the same path and the paths will be identical on both machines, this is probably the most common option.

3. nfsbus.pl then attempts to mount www.backupserver.com:/var/nfstemp. 
If successful, it mounts it to the same local directory, /var/nfstemp.

4. /home/httpd/docs is then copied to /var/nfstemp/docs
and /usr/local/pgsql/data is then copied to /var/nfstemp/data

5. /var/nfs/.destinations is written with the following data:
docs /home/backup
data /usr/local/pgsql

6. /var/nfstemp is unmounted and the program exits.

www.backupserver.com [server where backup data is stored safely]

1. crontab is set to automatically run:

/usr/local/bin/nfsbuc.pl /var/nfstemp admin@mainserver.com

every day at 8am.

2. nfsbuc.pl looks for /var/nfstemp/.destinations and finds it has:
docs /home/backup
data /usr/local/pgsql

inside.

3. It then checks to see whether /var/nfstmp/docs does actually exist, and if so it sees whether an older copy exists at the specified location of /home/backup/docs and if so, removes that and replaces it with the new copy from /var/nfstemp/docs

4. It repeats this for the /var/nfstemp/data directory as well.

5. It removes everything from /var/nfstemp and exits.

Contact the author:

[top]
You can contact me at wocky #NOSPAM# @ #NOSPAM# akibageeks dot com