Backup essential files.

#!/bin/bash
#
# creates backups of essential files
#
DATA=”/root”
CONFIG=”/etc”
WWW=”/srv/www/htdocs/”
LIST=”/tmp/backlist_$$.txt”
#
cd /backup
set $(date)
#
if test “$1” = “Sun” ; then
# weekly a full backup of all data and config settings:
#
tar cfz “/backup/data/data_full_$6-$2-$3.tgz” $DATA
rm -f /backup/data/data_diff*
#
tar cfz “/backup/config/config_full_$6-$2-$3.tgz” $CONFIG
rm -f /backup/config/config_diff*
#
tar cfz “/backup/www/www_full_$6-$2-$3.tgz” $WWW
rm -f /backup/www/www_diff*
else
# incremental backup
#
find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT “/backup/data/data_diff_$6-$2-$3.tgz” “$LIST”
rm -f “$LIST”
#
find $CONFIG -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT “/backup/config/config_diff_$6-$2-$3.tgz” “$LIST”
rm -f “$LIST”
#
find $WWW -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT “/backup/www/www_diff_$6-$2-$3.tgz” “$LIST”
rm -f “$LIST”
fi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s