Custom Search




Apache web server backup script


#!/bin/sh
# written by brent kevin krkosska
# temporarily stop editing of web pages until the backup job is finished:
/sbin/iptables -I INPUT -p tcp --dport 0/0 21 -j REJECT
/bin/sleep 5

/bin/echo " "


# create include file: specify what files to include/exclude
####### this example excludes nowhere.com
####### this is all one line:
/bin/find /apache/htdocs -path '/apache/htdocs/nowhere.com/logs' -prune -o -type f ! -name "*.gz" 
			! -name core ! -name "file.html" ! -name "*.bz2" ! -name "*.tgz" 
			-mtime -1 -print > /backup/include.$$

# the next few things could be done in one or two lines, but I like everything to be documented and easy to follow:
cp /backup/include.$$ /tmp/backuptofix.txt

# this line makes the completed file list into clickable links for Outlook Express:
perl -p -i -e 's/\/apache\/htdocs\//http\:\/\/www\./g' /tmp/backuptofix.txt

# create tar.gz file including selected files
/bin/echo "Backing up the following files: "
/bin/tar cf /backup/backup.tar -T /backup/include.$$
/bin/gzip /backup/backup.tar
/bin/echo " "
# move files
/bin/mv /backup/include.$$ /backup/packinglist-"`date +%B`-`date +%d`-`date +%Y`".txt
/bin/mv /backup/backup.tar.gz /backup/backup-"`date +%B`-`date +%d`-`date +%Y`".tar.gz

#/bin/echo "Your files are backed up in /backup"
/bin/ls -la /backup
/bin/sleep 5

# start accepting connections again
/sbin/iptables -D INPUT -p tcp --dport 0/0 21 -j REJECT

# line numbers in the email:
/bin/cat -n /tmp/backuptofix.txt > /tmp/backuptofixn.txt
mail staff < /tmp/backuptofixn.txt







www.fiveanddime.net








Custom Search