
BACKUP_SCRIPTS VERSION 1.1

This collection of bash shell scripts are meant to backup certain directories 
to the separate partition (directory) or remote backup server. Full backups 
will be run every month at 28.th day and incremental backups will be run 
every day. Incremental backups are maintained weekly as a separate files. 
This means that there is four to about nine weeks time schedule for 
the file recovery.

The backup_scripts version 1.1 was tested with RedHat 9. However other 
UNIX platforms should be fine if the code is modified.

DAILY BACKUPS

Daily backup shell script is called backup_daily.sh.

Daily backups are kept in the separate directory (variable's $daily default is
/mnt/backup/daily). Modification time of the file date.lock defines 
what files to be backed up. 

Variable $dirs defines what directories to be backed up. 
The default is "/home /root".

Daily incremental backup files are named 
<week day: Sun, Mon, etc.>.backup.tar.gz.

List of files in the daily backups are maintained separately. 
List of files are named <week day: Sun, Mon, etc.>.backup.tar.gz.txt.

File errors.txt holds errors that occurred during last backup procedure.

Content of daily backup directory will look like this 
(on Sunday before weekly backup script is run): 

date.lock
errors.txt
Mon.backup.tar.gz.txt
Mon.backup.tar.gz
Tue.backup.tar.gz.txt
Tue.backup.tar.gz
Wed.backup.tar.gz.txt
Wed.backup.tar.gz
Thu.backup.tar.gz.txt
Thu.backup.tar.gz
Fri.backup.tar.gz.txt
Fri.backup.tar.gz
Sat.backup.tar.gz.txt
Sat.backup.tar.gz
Sun.backup.tar.gz.txt
Sun.backup.tar.gz

If any errors occurred during daily backup procedure a mail message 
is sent to the root.

WEEKLY BACKUPS

Weekly backup shell script is called backup_weekly.sh.

Weekly backups are kept in the separate directory (variable's $weekly default 
is /mnt/backup/weekly). 

Weekly backup files are named
<week number: 01, 02, etc.>.<month name: Jan, Feb, etc.>.backup.tar.
Weekly backup will be run every week on Sunday. 

List of files in the weekly backups are maintained separately. 
List of files are named 
<week number: 01, 02, etc.>.<month name: Jan, Feb, etc.>.backup.tar.txt.

Contents of weekly backups are the files that appeared in 
the daily backup directory i.e. one weekly backup file contains 
daily incremental backups.

File errors.txt holds errors that occurred during last backup procedure.

Typical content of weekly backup directory will look like this (before 
October's monthly backup script is run):

errors.txt
36.Sep.backup.tar.txt
36.Sep.backup.tar
37.Sep.backup.tar.txt
37.Sep.backup.tar
38.Sep.backup.tar.txt
38.Sep.backup.tar
39.Sep.backup.tar.txt
39.Sep.backup.tar
40.Oct.backup.tar.txt
40.Oct.backup.tar
41.Oct.backup.tar.txt
41.Oct.backup.tar
42.Oct.backup.tar.txt
42.Oct.backup.tar
43.Oct.backup.tar.txt
43.Oct.backup.tar

If any errors occurred during weekly backup procedure a mail message 
is sent to the root.

MONTHLY BACKUPS

Monthly backup shell script is called backup_monthly.sh.

Monthly backups are kept in the separate directory (variables $monthly 
default is /mnt/backup/monthly). 

Variable $dirs defines what directories to be backed up. 
The default is "/home /root".

Monthly full backup files are named
<month name: Jan, Feb, etc.>.backup.tar.gz.
Monthly full backups will be run every month at 28.th day.

List of files in the monthly backups are maintained separately. 
List of files are named <month name: Jan, Feb, etc.>.backup.tar.gz.txt.

File errors.txt holds errors that occurred during last backup procedure.

Typical content of monthly backup directory will look like this 
(before October's monthly backup script is run): 

errors.txt
Sep.backup.tar.gz.txt
Sep.backup.tar.gz

If any errors occurred during monthly backup procedure a mail message 
is sent to the root.

After monthly backup have been successfully run previous months' full backups
and weekly incremental backups will be removed. For example after October's 
monthly backup is run, the monthly backup directory will look like this:

errors.txt
Oct.backup.tar.gz.txt
Oct.backup.tar.gz

And the weekly backup directory will look like this:

errors.txt
40.Oct.backup.tar.txt
40.Oct.backup.tar
41.Oct.backup.tar.txt
41.Oct.backup.tar
42.Oct.backup.tar.txt
42.Oct.backup.tar
43.Oct.backup.tar.txt
43.Oct.backup.tar

This means that there is four to about nine weeks time schedule 
for the file recovery.

CRON AND ANACRON

The backup_scripts should be run as a cron job so that backup_daily.sh will be 
run every day before backup_weekly.sh, backup_weekly.sh will be run 
every week on Sunday before backup_monthly.sh and backup_monthly.sh will be 
run every month at 28.th day. An example of cron job configuration file is
given in the file called backups. Copy this file to the /etc/cron.d/ and modify
times as needed.

However if the computer is not always on (for example if the computer is 
a workstation), the backup_scripts could be run as a anacron job. An example 
of anacron job configuration file is given in the file anacrontab. Insert these
configurations to the /etc/anacrontab and modify times as needed.

INSTALLATION (RedHat 9)

1) Log in as a root

2) Create backup directory

$ mkdir /mnt/backup

[ Option: Mount backup directory from the remote backup computer

Insert following line to the /etc/fstab

backup.localdomain:/opt/backups/server_name    /mnt/backup	nfs	rsize=8192,wsize=8192,timeo=14,intr

where backup.localdomain is a NFS server and /opt/backups/server_name is 
a remote NFS share.

Mount remote backup directory to the local backup directory:

$ mount /mnt/backup

]

3) Create daily, weekly and monthly backup directories

$ mkdir /mnt/backup/daily
$ mkdir /mnt/backup/weekly
$ mkdir /mnt/backup/monthly

4) Create file date.lock for the incremental backups to the daily backup 
   directory

$ touch /mnt/backup/daily/date.lock

5) Create backup_scripts directory

$ mkdir /opt/backup_scripts

6) Unpack backup_scripts_v1_1.tar.gz to the backup_scripts directory

$ cp backup_scripts_v1_1.tar.gz /opt/backup_scripts
$ cd /opt/backup_scripts
$ tar -xzvf backup_scripts_v1_1.tar.gz

7) Change backup_scripts shell file owner and permissions

$ chown root:root /opt/backup_scripts/backup_scripts_v1_1
$ chown root:root /opt/backup_scripts/backup_scripts_v1_1/*
$ chmod 700 /opt/backup_scripts/backup_scripts_v1_1/*.sh

8) Modify /opt/backup_scripts/backup_scripts_v1_1/*.sh shell files as needed

Modify variable $dirs as needed i.e. 
insert directories you would like to backup to this variable. 
The default is "/home /root".

9) Make backup_scripts run as a cron or anacron job

For the Server: 
$ cp /opt/backup_scripts/backup_scripts_v1_1/backups /etc/cron.d
For the Workstation: Insert appropriate lines from the
                     /opt/backup_scripts/backup_scripts_v1_1/anacrontab
		     to the /etc/anacrontab

Modify running times of /etc/cron.d/backups or /etc/anacrontab as needed.

10) Backup_scripts is now ready to run, test the installation

----------------------------------------------------------------------------

The backup_scripts version 1.1 is copyright (C) by Mika Panhelainen 
(alias mpan) 2006

The backup_scripts version 1.1 is licensed under Historical Permission Notice 
and Disclaimer license approved by Open Source Initiative (OSI). 

Best regards, Mika Panhelainen <Mika.Panhelainen@iki.fi>

----------------------------------------------------------------------------

Historical Permission Notice and Disclaimer

Copyright notice: This software is originally copyright (C) by Mika Panhelainen 2003, 2006
Copyright holder: Mika Panhelainen
Related entities:

Permission to use, copy, modify and distribute this software and its 
documentation for any purpose and without fee is hereby granted, provided 
that the above copyright notice appear in all copies, and that both 
the copyright notice and this permission notice appear in supporting 
documentation, and that the name of copyright holder or related entities 
not be used in advertising or publicity pertaining to distribution of 
the software without specific, written prior permission. Copyright holder 
makes no representations about the suitability of this software for any 
purpose. It is provided "as is" without express or implied warranty.

Copyright holder DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT 
SHALL copyright holder BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

----------------------------------------------------------------------------

VERSION HISTORY

v1.1, 1/2006:
	- List of files in the weekly backups added
	- Minor corrections to the backups, anacrontab and readme.txt
	- Using .tar.gz instead of .tar as a package
	- Historical Permission Notice and Disclaimer license added

v1.0, 10/2003:
	- First release version
	- Automatic previous monthly full backups removal added
	- /bin/sh changed to the /bin/bash for the clarity
	- Spell checked

v0.9, 9/2003:
	- Version numbering added
	- Error message sending to the root added
	- Published in the news groups sfnet.atk.linux.palvelimet and 
	sfnet.tietoliikenne.palvelimet 

vUNNUMBERED, 9/2003: 
	- Published in the news groups sfnet.atk.linux.palvelimet and
	sfnet.tietoliikenne.palvelimet

vINITIAL, 9/2003:
	- Initial version
	- Made as a voluntary work to the Kotikartanoyhdistys ry
