Backup question

Bill Moran wmoran at potentialtech.com
Wed Jun 9 08:04:35 PDT 2004


Karen Donathan <donathan at gwhs.kana.k12.wv.us> wrote:

> Hello.
> 
>      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!

Ah ... a neophyte unwittingly asking to be taught the magic of shell-scripting.

Yes, you can do everything you ask.  The trick is to write a shell script to
automate it for you, then add the shell script to cron to be automagically
executed on a schedule.

Here's my suggestion:
1) Study the attached shell script, it backs up to a seperate HDD, but it'll
   give you an idea of how things work
2) Read up on "man mail" to learn how to use the mail program from a shell
   script
3) Write your own and test it from the command line.
4) Add a cron entry to automate it.
5) Once you're getting good backups, look into using rsync to make the process
   even smoother.

<begin simple backup shell script>
#!/bin/sh
 
# Takes the files in /backup/source and bzips them into an
# archive in /backup/archive
# Also deletes archive files older than a certain amount
 
DATE=`/bin/date "+%F"`
MAXAGE=14
 
/usr/bin/tar cyf /backup/archive/backup-${DATE}.tbz /backup/source > /dev/null 2>&1
/usr/bin/find /backup/archive -mtime ${MAXAGE} -delete
<end simple backup shell script>

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com


More information about the freebsd-questions mailing list