Tag ‘amazon’ » Archiv


Configuring Hostgator VPS for automated CPanel backups to Amazon S3


Warning! Geekiness ahead

Ok, so just had a wonderful time trying to set up a way to automatically backup my hostgator VPS to Amazon S3.

I did it with the help of some googling, head scratching and tricky bastardness so I thought I’d better document it here to remind me how to do it when I need to do it again.

I got most of the information from the post here and in the comments. Although, I had to piss about a lot to get it finally working. Mainly because of curly quotes in the original page, windoze line breaks and my monkey heritage.

(this is for VPS on Hostgator running Centos 5)

1. Create AmazonS3 bucket

Easy bit here, just create a bucket

2. Install S3 client for Linux

First need to install s3tools repo

cd /etc/yum.repos.d
wget http://s3tools.org/repo/CentOS_5/s3tools.repo

Next need to install

yum install s3cmd

Answer the questions with Y

3. Configure s3cmd

s3cmd --configure

Enter in the access key and secret key from Amazon Security Credentials

4. Enable daily backups from WHM

You can select which accounts by clicking the button marked ‘select’

If it’s already configured, find out the backup directory by typing

grep BACKUPDIR /etc/cpbackup.conf

5. Create the log directories

mkdir /var/log/backuplogs

6. Write a script to automate the backup and save it as /root/dailybackup.sh

You should change the email and bucket name to reflect your own values


##Notification email address

ERRORLOG=/var/log/backuplogs/backup.err`date +%F`
ACTIVITYLOG=/var/log/backuplogs/activity.log`date +%F`

##Directory which needs to be backed up

##Name of the backup in bucket

##Backup degree

#Clear the logs if the script is executed second time

##Uploading the daily backup to Amazon s3
/usr/bin/s3cmd -r put ${SOURCE} s3://yourbucketname/${DESTINATION}/ 1>>${ACTIVITYLOG} 2>>${ERRORLOG}

##Sent email alert

if [ $ret2 -eq 0 ];then
msg1="Amazon s3 Backup Uploaded Successfully"
msg1="Amazon s3 Backup Failed!!\n Check ${ERRORLOG} for more details"
echo -e "$msg1"|mail -s "$msg" ${_EMAIL}

##Deleting backup’s older than DEGREE days
## Delete from both server and amazon
DELETENAME=$(date --date="${DEGREE} days ago" +%F)

/usr/bin/s3cmd -r --force del s3://yourbucketname/${DELETENAME} 1>>${ACTIVITYLOG} 2>>${ERRORLOG}

7. Grant execute privilege to the script

chmod u+x /root/dailybackup.sh

8. Set up a cpanel hook to run the script after the backup has completed

nano /scripts/postcpbackup

enter this as the contents


make it executable

chmod u+x /scripts/postcpbackup

That’s it!

In case of disaster, copy the file from Amazon s3 with

mkdir restore
s3cmd -r get s3://yourbucketname/2011-02-32/filename.gz restore

I changed the bash script so it only copies *.gz files
I wanted to change the time at which the cpbackup occurs so I went to ‘manage plugins’ in WHM and put ‘install and keep udpated’ tick on ‘cronconfig’ and then went to ‘configure cpanel cron times’ and set the time I wanted cpbackup to run.

Blog Tools, linux


Ban the cloud!


Take a look at this server load graph showing how much the server was working (on ComLuv.com) for 24 hours..

Seems normal right? that’s right! because my UKFast host detected a spike of 70,000 or so hits coming in to the comluv signup page from an Amazon cloud server and within 30 seconds added their IP to my firewall so it can appear normal again but, look at the next pic after the ad break to see what a difference the banning made..

server load graph


Blog News

Comments Off

5 Star Christmas Gadgets


I, for some reason, have a subscription to T3 magazine. I think I must have crumbled under the power of one of Future Publishing’s telesales reps and agreed to try a few issues for 1p, now I have a direct debit and get the magazine delivered monthly. It’s not bad though and there’s always something to read when I need a poo (sorry! it’s true though).

I was going to download and edit pictures of their fantasy Christmas presents and do my own write up but, I have been playing with Amazons widgets and came up with this.. it’s pretty clever and easy to build..

Amazon.co.uk Widgets

Not bad for a few minutes work, I think I can work on this some more, combining it with some decent write-ups and other value added information and it will look at home within a post and provide convenient links to the products.

I think this post still needs it’s own pictures and descriptions for the gadgets as well as the slideshow box, what do you think?

Making / Made Money, Reviews

Comments Off

Resistance is futile, prepare to be affiliated…


Affiliate Borg
I am an affiliate with a lottery site and have been for a few years now to great success but, I have never really entered the realm of affiliate marketing with products before. Apparently it is supposed to be an ok earner if you have enough traffic (and enough sites) to make it worthwhile.

I get between 200 and 500 uniques a day here, do you think that would be enough to monetize this blog with affiliate products?

I’m not sure, I’ve never been one to recommend stuff just to earn money off it but I have some decent reviews to write about after my new theme is here (still no word from the designer yetI heard from him and it’s probably the best theme I have ever seen!) and it would be nice to offer people that read the reviews a convenient way to purchase the product (and for a little trickle of coins to come my way if they do).

I have seen the likes of TradeDoubler and Amazon associates all over the place, if you use either or both of them I would be interested in hearing your experience of them. Did they make you any money? are they worth it?

How about successful ways that you have monetized your blog? I’m lucky enough to earn a fair amount from my TeamPlayLotto site, full time job and my own company so earning megabucks within a microsecond of blogging time is not really a high priority for me so I’d just like to experiment with some things so I can use the experience for monetizing clients’ sites, if I can get some detailed knowledge of money making website tools then I can pass that along with the clients project (along with an extra charge of course!) and then put some of that money to use for fabulous competitions! …. that would be nice, a self financing contest blog..

Any affiliate experiences you want to share?

Making / Made Money