Wit Inc
Custom Web Programming
Call 586-693-2599
Server-Pak

Overview

System Requirements

Documentation

License

Pricing


Home > Tools > Server-Pak

Documentation

---------------------------------------------------
To create a full backup on the first run
--------------------------------------------------
rm last-full-date-files
rm last-full-date-mysql
rm last-full-date-site

----------------------------------------------------
Archive files will have following format:
----------------------------------------------------
FILES-YYYY-MM-DD-Monthly.zip (.tar.gz)
FILES-YYYY-MM-DD-Weekly.zip (.tar.gz)
FILES-YYYY-MM-DD-Daily.zip (.tar.gz)

SITEXX-YYYY-MM-DD-Monthly.zip (.tar.gz)
SITEXX-YYYY-MM-DD-Weekly.zip (.tar.gz)
SITEXX-YYYY-MM-DD-Daily.zip (.tar.gz)

MYSQL-[dbname]-YYYY-MM-DD-Monthly.zip (.tar.gz)
MYSQL-[dbname]-YYYY-MM-DD-Weekly.zip (.tar.gz)
MYSQL-[dbname]-YYYY-MM-DD-Daily.zip (.tar.gz)

--------------------------------------
Individual site archive option
--------------------------------------
By default, the individual site archive option assumes that each site directory is organized in a single parent folder and starts with "site" and ends with a number as follows:

site01
site02
...
site99

This behavior can be changed by modifying the build_list_of_sites.sh script.

Installation

mkdir /home/archive
mkdir /home/archive/bin
mkdir /home/archive/log
cd /home/archive
tar xvfz backup.tar.gz

Configuration Settings

# create file archive?, 0=no, 1=yes
FILES_BACKUP=1

# create mysql archive?, 0=no, 1=yes
MYSQL_BACKUP=1

# create site archive?, 0=no, 1=yes
SITE_BACKUP=1

# specify if you want to copy the file archive to a remote server.  
# 0=no, 1=yes
REMOTE_FILES_COPY=1

# specify if you want to copy the database archive(s) to a remote server.  
# 0=no, 1=yes
REMOTE_MYSQL_COPY=1

# specify if you want to copy the site archive(s) to a remote server.  
# 0=no, 1=yes
REMOTE_SITE_COPY=1

# specify zip format as "tar" or "zip"
ZIP_FORMAT="zip"

#----------------------------------------------
# for the files backup:
# specify what directories to backup
# do not include the leading "/"
# do not include symbolic links
#----------------------------------------------
SRC_DIR[1]="etc/dnscache"
SRC_DIR[2]="etc/httpd"
SRC_DIR[3]="etc/sysconfig/network-scripts"
SRC_DIR[4]="etc/tinydns"
SRC_DIR[5]="home/fastpitch"
SRC_DIR[6]="home/archive/bin"
SRC_DIR[7]="home/archive/log"
SRC_DIR[8]="inetpub/.gnupg"
SRC_DIR[9]="root"
SRC_DIR[10]="usr/local/proftpd/conf"
SRC_DIR[11]="end_of_list"

#--------------------------------------------------
# specify what individual files to backup
# do not include the leading "/"
#--------------------------------------------------
SRC_FILE[1]="etc/bashrc"
SRC_FILE[2]="etc/crontab"
SRC_FILE[3]="etc/dnsroots.global"
SRC_FILE[4]="etc/group"
SRC_FILE[5]="etc/hosts"
SRC_FILE[6]="etc/hostname"
SRC_FILE[7]="etc/ld.so.conf"
SRC_FILE[8]="etc/my.cnf"
SRC_FILE[9]="etc/passwd"
SRC_FILE[10]="etc/php.ini"
SRC_FILE[11]="etc/resolv.conf"
SRC_FILE[12]="etc/smtproutes"
SRC_FILE[13]="etc/sysconfig/iptables"
SRC_FILE[14]="etc/sysconfig/network"
SRC_FILE[15]="etc/tcp.smtp"
SRC_FILE[16]="end_of_list"

#--------------------------------------
# specify what files to exclude
#--------------------------------------
EXCLUDE_FILE[1]="home/mysql/mysql.sock"
EXCLUDE_FILE[2]="end_of_list"

#-------------------------------------------------------
# for the mysql backups:
# specify what mysql directories to backup
# do not include the leading "/"
#-------------------------------------------------------
MYSQL_SRC_DIR[1]="home/mysql_backup"
MYSQL_SRC_DIR[2]="end_of_list"

#----------------------------------------------------------
# specify what individual mysql files to backup
# do not include the leading "/"
#----------------------------------------------------------
MYSQL_SRC_FILE[1]="end_of_list"

#-----------------------------------------------
# specify what mysql files to exclude
#-----------------------------------------------
MYSQL_EXCLUDE_FILE[1]="end_of_list"

#----------------------------------------------------
# for the site backups:
# specify what site directories to backup
# do not include the leading "/"
#----------------------------------------------------
SITE_SRC_DIR[1]="inetpub"
SITE_SRC_DIR[2]="end_of_list"

#--------------------------------------------------------
# specify what individual site files to backup
# do not include the leading "/"
#--------------------------------------------------------
SITE_SRC_FILE[1]="end_of_list"

#--------------------------------------------------------
# specify what site files to exclude
#--------------------------------------------------------
SITE_EXCLUDE_FILE[1]="end_of_list"

#---------------------------------------------------------
# general settings:
# Create list of local and remote directories
# that need to be cleaned up
#---------------------------------------------------------
LOCAL_ARCHIVE_DIR[1]="/home/archive/amwebp01"
LOCAL_ARCHIVE_DIR[2]="end_of_list"

REMOTE_ARCHIVE_DIR[1]="/mnt/backup/amwebp01"
REMOTE_ARCHIVE_DIR[2]="end_of_list"

#-------------------------------------
# specify important file paths
#-------------------------------------
# specify the backup root directory, this will almost always be "/"
BACKUP_ROOT_DIR="/"

# specify the directory to save the archive files
DEST_DIR="/home/archive/amvpsp01"

# specify the path for the last-full-date file
FILES_LAST_FULL_DATE_PATH="/home/archive/bin/last-full-date-files"

# specify the path for the last-full-date file
MYSQL_LAST_FULL_DATE_PATH="/home/archive/bin/last-full-date-mysql"

# specify the path for the last-full-date file
SITE_LAST_FULL_DATE_PATH="/home/archive/bin/last-full-date-site"

# specify the path to bin directory
BIN_DIR="/home/archive/bin"

# specify a directory for the log files
LOG_DIR="/home/archive/log"

# specify the backup log filename
LOG_FILE=""`date '+%Y-%m'`"-backup.log"

# specify the temp log filename
TEMP_LOG_FILE="temp.log"

# specify the exclude file filename, this file is generated for use by zip (tar)
FILES_EXCLUDE_FILE="files_exclude_list"

# specify the mysql exclude file filename, this file is generated for use by zip (tar)
MYSQL_EXCLUDE_FILE="mysql_exclude_list"

# specify the site exclude file filename, this file is generated for use by zip (tar)
SITE_EXCLUDE_FILE="site_exclude_list"

# specify location of tar executable
TAR_BIN="/bin/tar"

# specify location of zip executable
#ZIP_BIN="/usr/bin/zip"
ZIP_BIN="/usr/local/bin/zip"

# file name for files error log
FILES_ERR_LOG="files_error.log"

# file name for mysql error log
MYSQL_ERR_LOG="mysql_errors.log"

# file name for site error log
SITE_ERR_LOG="site_errors.log"

# root directory of web site directories
SITES_ROOT_DIR="/inetpub"

# specify the name of the file that records the archives created.
# this file will be used by the rsync process to transfer the files.
FILES_ARCHIVE_LIST="archive_list_files"
SITE_ARCHIVE_LIST="archive_list_site"
MYSQL_ARCHIVE_LIST="archive_list_mysql"

# specify temp file used to create a list of mysql databases
MYSQL_UNIQUE_LIST="unique_list_mysql"

# specify temp file used to create a list of sites
SITE_UNIQUE_LIST="unique_list_site"

# set remote transfer mode
# valid options are "local_mount" or "remote_server"
RSYNC_MODE="local_mount"

#-------------------------------------------------------
# specify the local mount location
# used if RSYNC_MODE="local_mount"
#-------------------------------------------------------
LOCAL_MOUNT_DIR="/mnt/backup/amwebp01"

#-------------------------------------------------------
# specify remote server information
# used if RSYNC_MODE="remote_server"
#-------------------------------------------------------

# transfer speed of scp (in Kbit/s)
SCP_TRANSFER_SPEED="1500"

# remote user for scp-transfer.sh
REMOTE_USER=""

# remote server name for scp-transfer.sh
REMOTE_HOST=""

# remote password for scp-transfer.sh
REMOTE_PWD=""

# destination path of archive file for scp-transfer.sh
REMOTE_ARCHIVE_DEST_DIR="/home/archive/amvpsp01/"

#-----------------------------
# specify date settings
#-----------------------------

# specify date of monthly backups
MONTHLY_DOM="01"

# specify day of weekly backups
# Sun, Mon, Tue, Wed, Thu, Fri, Sat
WEEKLY_DOW="Mon"

#--------------------------------
# specify archive settings
#--------------------------------

# specify the maximum number of monthly backups to retain
# monthly backups are full
# weekly backups are full
# set this value to '0' if you do not want backups
MAX_MONTHLY_LOCAL_ARCHIVES=0
MAX_WEEKLY_LOCAL_ARCHIVES=4
MAX_DAILY_LOCAL_ARCHIVES=6

MAX_MONTHLY_REMOTE_ARCHIVES=0
MAX_WEEKLY_REMOTE_ARCHIVES=8
MAX_DAILY_REMOTE_ARCHIVES=6

# specify the maximum number mysql archive files to retain
MAX_MONTHLY_LOCAL_MYSQL=0
MAX_WEEKLY_LOCAL_MYSQL=4
MAX_DAILY_LOCAL_MYSQL=6

MAX_MONTHLY_REMOTE_MYSQL=0
MAX_WEEKLY_REMOTE_MYSQL=8
MAX_DAILY_REMOTE_MYSQL=6

# specify the maximum number mysql archive files to retain
MAX_MONTHLY_LOCAL_SITE=0
MAX_WEEKLY_LOCAL_SITE=4
MAX_DAILY_LOCAL_SITE=6

MAX_MONTHLY_REMOTE_SITE=0
MAX_WEEKLY_REMOTE_SITE=8
MAX_DAILY_REMOTE_SITE=6

#-------------------------------------
# specify email confirmation settings
#-------------------------------------

# specify "to address" for email confirmations
# leave blank if you don't want to send out email confirmations
TO_ADDRESS="yourname@yourdomain.com"

# specifiy "from address" for email confirmations
FROM_ADDRESS="webserver@yourdomain.com"

# specify "cc address" for email confirmations
CC_ADDRESS=""

# specify "bcc address" for email confirmations
BCC_ADDRESS=""

# specify name of server for email confirmations
#SERVER_NAME="`uname -n`"
SERVER_NAME="[amwebp01]"

Running Backup

 cd /home/archive/bin
./backup.sh

---------------------------------------
Additional Run-Time Options
---------------------------------------
./backup.sh --force_monthly
./backup.sh --force_weekly
./backup.sh --force_daily

Schedule Backup

Add the following line to /etc/crontab:
00 3 * * * root /home/archive/bin/backup.sh

The above line will automatically execute a backup everyday at 3:00AM.