[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: help on a script

On Sat, 2004-06-05 at 06:48, Computer Nick wrote:
> Ive never used a cron job before or written that big of a script and was
> hoping someone on this list could help me out, and tell me if it can be done
> or not.  I want to make a script that once a week, tar up my mail on my mail
> server, copy it to another drive and send it to another machine over the
> internet as a second backup, like on Sunday at 11pm.  Is there a way to do
> this and if so how? Has anyone already made something like this that they
> could send me to look at? any help would be greatly appreciated. 

The script (let's call it /usr/local/bin/mail-backup).  Substitute real
values for the bits in square brackets:

        #! /bin/bash
        BACKUP_DIR=[backup directory]
        tar czf $BACKUP_DIR/mail.backup.tar.gz [mail directory name]
        scp $BACKUP_DIR/mail.backup.tar.gz [other machine]:[target directory name]

Make the script executable and make sure the user under whose uid it
will run is able to connect with ssh without supplying a password.

In /etc/crontab:

        01  23  *  *  Sunday  [username] /usr/local/bin/mail-backup

Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
     "Let your conversation be without covetousness; and be 
      content with such things as ye have. For he hath said,
      I will never leave thee, nor forsake thee."      
                                             Hebrews 13:5 

Reply to: