7. Backup

Most of the configuration files and scripts that are specific for this webserver, are kept in the directory /usr/local/config/, so that they can be accessed and backed up easily. Even the config files that are not in this directory have a symbolic link inside it for easy access and for having a clear idea of the config files that are modified after the installation. A listing of this directory looks like this:

bash$ cd /usr/local/config/
bash$ ls -R
.:
backup.sh         network.cfg    network.cfg.3  slinks
config-files.txt  network.cfg.1  network.sh     test.sh
firewall          network.cfg.2  reconfig.sh

./firewall:
forward-rules.sh  iptables.sh             port-forward.sh  samba-rules.sh
input-rules.sh    local-network-rules.sh  port.sh          source-nat.sh

./slinks:
grub.conf  rc.local  smb.conf

The backup of configuration files and scripts is done by the script backup.sh:

#!/bin/bash

path=$(dirname $0)

tar --create --verbose --preserve-permissions --gzip \
    --file config.tgz \
    --files-from=$path/config-files.txt

### it can be like this as well:
#tar cvpfz config.tgz --files-from=$path/config-files.txt

The script backs up all the files that are listed in the file config-files.txt :

bash# vi config-files.txt
/boot/grub/grub.conf
/etc/samba/smb.conf
/etc/rc.d/rc.local
/usr/local/config/

Maybe you want to backup the website of the organization as well. To do this, append the line /var/www/html/ to the file above. Alternatively, append the command tar cvpfz www.tgz /var/www/html/ to the backup script.

In order to perform another installation of a server like this one, or a re-installation of the same server, the backup file config.tgz is placed in the installation server:

bash$ ssh username@11.22.33.44 mkdir -p /var/www/html/backup/
bash$ scp config.tgz username@11.22.33.44:/var/www/html/backup/

Also, they can be backed up in the Rescue partition (together with other useful data), so that they can be accessed easily in case of re-installation:

bash# mkdir /mnt/hda1
bash# mount /dev/hda1 /mnt/hda1
bash# mkdir -p /mnt/hda1/backup
bash# cp config.tgz /mnt/hda1/backup/
bash# cp www.tgz /mnt/hda1/backup/
bash# umount /mnt/hda1