archive - selectively archives and deletes old files on a remote host
archive
[[
-b
] | [[
-f
] | [
-r
[
-D
]]] [
-c
<config>
] [
-d
] [
-l
] [
-v
]
[
-z
]
-h
<host_name>
|
-V
archive is a Bourne shell script which should work equally well on all versions of UNIX and Linux.
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.
-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.
-h <host_id> The <host_id> is used to find the required perameters in the configuration file archive.cf and is required for the script to run.
-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.
-D set the --delete option for rsync .
-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.
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.
The script is quite crude and has little or no error checking.
Clifford W Fulford, City Linux. Contact fulford@citylinux.com or +44 (0)793 572 8612.
Copyright
© 2003-2017
Clifford W Fulford.
Fulford Consulting Ltd.
Regd. Co. 4250037 in England & Wales.
Regd. office 162, Edward Rd. Nottingham NG2 5GF, England, UK.
Related web sites: City Linux | Flare Support | West Bridgford | Fulford Portal | Joan Mary Fulford (Nottingham Writer) | Fulford Gallery | Amharic Interpreter | Arabic Interpreter | Tigrinya Interpreter
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.