Backup Script



# Remove previous backups to conserve on disk space
rm -f /backups/*

# Apt package list backup
dpkg --get-selections > /backups/dpkg_list_`date +%Y-%m-%d`.txt

# SQL dump
mysqldump -u root -pMYPASSWORD --all-databases > /tmp/mysqlbak
gzip /tmp/mysqlbak
mv /tmp/mysqlbak.gz /backups/dbbackup_`date +%Y-%m-%d`.sql.gz

# Filesystem backup
tar cfj /backups/fsbackup_`date +%Y-%m-%d`.tar.bz2 /etc /var /home

vnStat and vnstat PHP Frontend Installation – CentOS

Yum installation

yum install vnstat

Edit configuration

vim /etc/sysconfig/vnstat

I only have one interface (eth0), you may have more (eth1 etc…)

# see also: vnstat(1)
# starting with vnstat-1.6 vnstat can also be
# configured via /etc/vnstat.conf
# the following sets vnstat up to monitor eth0
VNSTAT_OPTIONS="-u -i eth0"

Edit configuration

vim /etc/vnstat.conf

Set your default interface

# default interface
Interface "eth0"

Setup your database

vnstat -u -i eth0

Start vnStat service

chkconfig vnstat on

Other commands for vnStat

service vnstat start
service vnstat stop
service vnstat restart
service vnstat status

Check if installation has been successful

vnstat -i eth0

Run –help for more commands

vnstat --help

Now install php front end.
Install these if not already installed

yum install httpd php php-gd

Go to the directory you want to install the frontend. i.e.

# make directory
mkdir /home/domain/public_html/vnstat
# change to directory
cd /home/domain/public_html/vnstat
# download frontend files
# untar file
tar xvf vnstat_php_frontend-1.5.1.tar.gz
# delete tar file
rm -f vnstat_php_frontend-1.5.1.tar.gz

Configure vnStat php frontend

vim /home/domain/public_html/vnstat/config.php

Look for the following Strings and edit them

$language = 'en';
$iface_list = array('eth0');
$iface_title['eth0'] = 'Internal';

Check if frontend has been installed correctly

If you get the following error:

This page contains the following errors:

error on line 10 at column 10: error parsing attribute name
Below is a rendering of the page up to the first error.

Edit your config.php file

vim /home/domain/public_html/vnstat/config.php

Look for

// graphics format to use: svg or png

Replace svg with png

// graphics format to use: svg or png

CSF Firewall Blocking VPN Internet Access

My CSF firewall seemed to be blocking internet access using my VPN. I could connect to it but could not use the internet connection. Here is a solution to the problem:

Create File

vim /etc/csf/ 

Insert This

iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT 
iptables -A INPUT -i eth0 -p gre -j ACCEPT 
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 
iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT 
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT 

Save File and Give Executable Permissions

chmod +x /etc/csf/ 

Create File

vi /etc/csf/ 

Input Text down

service pptpd stop 
service pptpd start 

Save File and Give Executable Permissions

chmod +x /etc/csf/ 

Restart CSF

csf -r

Install SVN::Notify on CentOS

This assumes you already have an SVN repository setup.

First download perl pre-requisites:

yum install perl-CPAN
perl -MCPAN -e 'install SVN::Notify'
perl -MCPAN -e 'install SVN::Notify::HTML::ColorDiff'


yum install perl
perl -MCPAN -e 'install SVN::Notify'
perl -MCPAN -e 'install SVN::Notify::HTML::ColorDiff'

Next download SVN Notify from CPAN:

cd /home
tar zxf SVN-Notify-2.83.tar.gz
cd SVN-Notify-2.83/

Next run MAKE:

perl Build.PL
./Build test
./Build install

If that doesn’t work then try:

perl Makefile.PL
make test
make install

Now change to your SVN directory and then to the hooks directory:

cd /%SVN LOCATION HERE%/hooks/

Create a post-commit file using vim:

vim post-commit

Add this to the file (replace:

/usr/local/bin/svnnotify -r $REV -C -d -H HTML::ColorDiff \
-p $REPOS -t --from \

Save the script and give it execution permission:

chmod +x post-commit

Now every time someone commits to the SVN repository, an email notification will be sent.