Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX sample scripts - archive

NAME

archive - selectively archives and deletes old files on a remote host

SYNOPSIS

archive [[ -b ] | [[ -f ] | [ -r ]] [ -c <config> ] [ -d ] [ -l ] [ -v ] [ -z ] <host_name> | -V

AVAILABILITY

archive is a Bourne shell script which should work equally well on all versions of UNIX and Linux.

DESCRIPTION

archive creates a full backup of local or remote systems using tar or lftp's mirror command. Only local file systems will be included in the archives and the script will attempt to avoid including any cdroms, dvds or loop back file systems.

OPTIONS

-b    back up the databases only. (See -f    option below.

-c <config_file>
The default configuration file is /usr/local/etc/archive.cf . An alternative configuration file may be set with the -c    option on the command line.

-d sets the script to debug mode (ie. runs with the shell option -x)

-f    backup up the file system only. It is an error to use the -f    option together with either the =b or the -r    option.

-l    turns on logging using the syslog facility. This is particularly useful where statistics are being compiled for presentation to the client, see report.

-r    perform rsync only. It is an error to combine the -r    option with either the -b    or the -b    options.

-v Sets the script to verbose mode. Each significant action will be reported on standard out.

-z    Use gzip to compress the tar file and append .gz to the archive filename. The -z    option is meaningless when a remote system is being archived as the tar file is always compressed prior to transmission across the network.

-V    prints version details to standard out and exits.

EXAMPLES

5 0 * * * su fulford -c "/usr/local/etc/archive -l albert"

The above is an extract from a root crontab file and illustrates the typical use of the script in practice. All the local file systems on the host "albert" will be backed up to device (or file) nominated in the default configuration file /usr/local/etc/archive.cf . Initiation and completion of the script will be logged using the syslog facility.

Note that the script is executed with an ordinary user id. This is to facilitate remote access where root logins are denied. Sudo is used within the script where root access is required.

NB. The hostname albert is being resolved locally and does not require a fully qualified domain.

BUGS

The script is quite crude and has little or no error checking.

FILES

archive.cf.

SEE ALSO

clean, ftchbkup, plbkup.

AUTHOR

Clifford W Fulford, City Linux. Contact fulford@citylinux.com or +44 (0)793 572 8612.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.