Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2004 11:04:33 -0400
From:      Bill Moran <wmoran@potentialtech.com>
To:        Karen Donathan <donathan@gwhs.kana.k12.wv.us>
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: Backup question
Message-ID:  <20040609110433.2827e926.wmoran@potentialtech.com>
In-Reply-To: <20040609102723.H167@gwhs.kana.k12.wv.us>
References:  <20040609102723.H167@gwhs.kana.k12.wv.us>

next in thread | previous in thread | raw e-mail | index | archive | help
Karen Donathan <donathan@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040609110433.2827e926.wmoran>