Backup question
Matthew Seaman
m.seaman at infracaninophile.co.uk
Wed Jun 9 08:06:11 PDT 2004
On Wed, Jun 09, 2004 at 10:29:27AM -0400, Karen Donathan wrote:
> What is the best way to back up the html directory? We do not have a
> tape drive. Is there a way to have an automated .tar file created and
> sent as email so I could save it on another server? Any help would be
> great!
Yeah. This sort of thing is easy to do with a very small shell
script. From your specifications, something like this will do the
job:
#!/bin/sh
PATH=/bin:/usr/bin ; export PATH
htmldir=/usr/local/www/data
recipient="somebody at example.com"
today=$(date +%Y%m%d)
tar -cvjf - ${htmldir} | uuencode backup-${today}.tar.bz2 | \
mail -s "Backup of ${htmldir} on ${today}" ${recipient} \
>>/var/log/backup.log 2>&1
Save that to a file, make it executable and run it out of root's
crontab on a daily basis:
@daily /usr/local/bin/mybackupscript
(be sure you understand the difference between /etc/crontab and
/var/cron/tabs/root, and how to use crontab(1) correctly: do *not*
feed /etc/crontab into the crontab command.)
The recipient should use procmail or similar to feed the backup
messages into uudecode and so extract the compressed tar file.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040609/5c79d946/attachment-0001.bin
More information about the freebsd-questions
mailing list