We need have a trusted system with a FTP account:
OS: | -some- |
FTP: | Yes, with one account, that can have rights to upload BIG FILES |
Disk space: | Enought for backups |
External storage: | ZIP, Tape, CDROM etc... (it can be on different system, that can have network access to same system, Ms Windows network or NFS for example) |
All backups will be stored into our FTP account home directory ('/var/backup' for example), and when we deside we can put it on CD Rom or tape (every few mounths, or every week...:)
Ok this is the main topic.
We must deside following things:
... # at 3:00am on every 1st day of week (possibly monday:)) 0 3 * * 1 /root/cron/full_backup ... |
Where /root/cron/full_bckup is file like this:
#!/bin/sh tape /www www tape /var/named named tape /etc etc tape /usr/local/apache/conf httpd #DONT THINK THAT THIS IS MY (YOURS) REAL DIRECTORIES :)))) #REPLACE THEM :)))) |
And in the end the BIG tape script. It must be in path.
#!/bin/sh ######################################## # # # THE TAPE 1.0 # # # # Copyleft Sep.1999, Nikolay Mijaylov # # # # nmmm@nmmm.nu http://www.nmmm.nu/ # # # # You can redistribute this script # # under terms of GPL. # # # # Please, if you have some another # # ideas about great modifications # # in this script, I WANT TO KNOW :) # # # ######################################## #=================================== #MAIN #=================================== #Directory for back up DIR=$1/ #Global name to backing up NAME=$2 #Backup system dir, where date files will be stored BACKUP_SYS_DIR=/root/cron/ #File name with date DATE_FILE=$BACKUP_SYS_DIR/.backup_date.$NAME #Directory where backup will be stored locally BACKUP_DIR=/var/backup/local/ #FTP Host where files should be uploaded FTP_HOST=trusted.foo.org #Mail of master MAIL_RCPT=nmmm@nmmm.nu #================================== #DATES #================================== #Date when time begins :))) DATE_BEGIN="1 jan 1980" #Today() DATE_TODAY=`date --utc` read_date(){ # Get the date DATE=`cat "$DATE_FILE" 2> /dev/null` # Check it if [ "$DATE" = "" ] ; then DATE="blah_blah" fi if ( date --date "$DATE" 1> /dev/null 2> /dev/null ) ; then # Fixing format, noo data change... DATE=`date --date "$DATE" --utc` ; else # Fixing date, reset to 01.01.1980 DATE=`date --date "$DATE_BEGIN" --utc` fi #tar --after-date $DATE -c * > hell.tar echo $DATE } #============================================================== #TAPE / GZIP #============================================================== #Date format DATE_FORMAT="%Y-%m-%d" #The date of last backup DATE=`read_date` #Backup file name (today).(last).(name) # FILE=`date +"$DATE_FORMAT"`.`date +"$DATE_FORMAT" --date "$DATE"`.$NAME cd $BACKUP_DIR # Tape it tar --after-date "$DATE" -c "$DIR" > "$FILE.tar" # Compress it rm -f "$FILE.tar.gz" gzip "$FILE.tar" #================================================================ # Set new backup date (today) #================================================================ echo "$DATE_TODAY" > "$DATE_FILE" #================================================================ # FTP it #================================================================ ftp $FTP_HOST << [DONE] put $FILE.tar.gz quit [DONE] #================================================================ #Mail it #================================================================ mail "$MAIL_RCPT" -s "backup ok, name=$NAME" << [DONE1] Hello Master, Backup was successfully maded. DATE LAST BACKUP: $DATE DATE THIS BACKUP: $DATE_TODAY NAME OF BACKUP : $NAME [DONE1] #================================================================ #Clean up #================================================================ #rm $FILE.tar.gz |
Description:
How to implement: