Tag Archives: S3

Secure your Minecraft server with offsite backups

Keeping incremental backups of your world folder may not be enough to prevent the loss of the your Minecraft server data. This guide will show you how to backup your entire server director to Amazon’s cloud storage solution, S3.  I chose S3 mainly because it was cheap, and had fast access speeds with redundant storage.  If you backup a 500MB world folder, you will probably spend less than $1 per month on your AWS bill.  My previous 6 bills have all been under 15 cents. S3 was also easier to use than some of the other offsite backup services I tried.

The tools I will show you how to use in this tutorial were s3fs and rsync.  The software s3fs will enable you to mount an Amazon S3 bucket directly to your linux filesystem. Please note this tutorial requires a moderate knowledge of linux command line interfacing. This tutorial was written for a system using Ubuntu 10.10 Server x86, but could be modified to fit any linux operating system.

The first step is to make sure you have the required dependencies for s3fs.  If using Ubuntu, your required packages are build-essential, libcurl14-openssl-dev, libxml2-dev and libfuse-dev.  Note that this tutorial will install s3fs version 1.33, which requires FUSE 2.8.4, which is a higher version than the 2.8.1 version currently supplied in the Ubuntu repositories. To install the packages in the repositories execute the following commands as root/sudo:

apt-get install build-essential libcurl4-openssl-dev libxml2-dev

To install the latest version of FUSE (currently 2.8.5), retrieve this package from sourceforge. Once you have the package, installation is typical of what you’d expect from source.

tar -xzf fuse-2.8.5.tar.gz && rm fuse-2.8.5.tar.gz
cd fuse-2.8.5
./configure
make
make install

Now that you have the dependencies installed, it’s time to install s3fs. Again, installation will be from source, as root/sudo.

wget http://s3fs.googlecode.com/files/s3fs-1.33.tar.gz
tar -xvf s3fs-1.33.tar.gz && rm s3fs-1.33.tar.gz
cd s3fs
./configure --prefix=/usr
make
make install

You now have all the necessary tools installed to automate your offsite backups. Next we will create a directory to mount our S3 bucket to. As root:

mkdir /mnt/backup
chown your_username_here:your_username_here /mnt/backup

For the next few steps, you will need your accessKeyID and secretAccessKey from Amazon. These can be located by navigating to http://aws.amazon.com, logging in and clicking “Account” from the top menu bar, and then “Security Credentials”. The required information is listed under “Access Credentials”. Once you have this information, it would be good to create a bucket for your backup. This can be accomplished easily from the AWS Management Console.

Now we will create the backup script that will rsync files to your bucket. The way the script will work by mounting the bucket, copying files and then unmounting the bucket. Keep in mind for minecraft, you may want to back up your entire server folder as opposed to simply your world folder.  Especially if you’re using Hey0 mod, you may need to backup plugin information from stuff like iConomy. Create the following script called backup.sh

#!/bin/bash
#backup.sh - Script by CheeseJaguar
/usr/bin/s3fs yourbucketname -o accessKeyId=your_access_key_ID -o secretAccessKey=your_secret_key /mnt/backup
/usr/bin/rsync -av --delete /path/to/folder/that/you/want/backed/up /mnt/backup
/bin/umount /mnt/backup

Save the script and make sure to chmod the script so that it is executable.

chmod +x backup.sh

Now all you need to do to backup your server is run

./backup.sh

If you’d like to automate the task, add a cronjob to your crontab. As root:

crontab -e

And add the line:

0 0 * * 0 /wherever/you/saved/it/backup.sh

This example line will backup your server every Sunday at 12:00AM. The 5 characters preceding your command tell the crontab how often to execute the command. The first character tells it which minute to execute, the second character tells it which hour to execute, the third character tells it which day of the month to execute, the fourth character tells it which month to execute, and the fifth character tells it the day of the week. Asterisks indicate every minute or hour or day,etc, and you can use commas to indicate multiple times. For example, 0,15,30,45 * * * * would execute every 15 minutes. For further reading, consult the Wikipedia article on Cron.

Once you have this setup, you will be automatically backing up cheaply and securely. Now let’s say for whatever reason someone took your server and threw it out the window of a high-rise. To get your world back, simply create a script with the source and destination parameters of the previous script, but switched. Like so:

#!/bin/bash
#restore.sh - Script by CheeseJaguar
/usr/bin/s3fs yourbucketname -o accessKeyId=your_access_key_ID -o secretAccessKey=your_secret_key /mnt/backup
/usr/bin/rsync -av /mnt/backup /path/to/put/your/files/in
/bin/umount /mnt/backup

This will bring your files back to your server, like nothing had happened (since the last backup, at least).

ASmallOrange + S3 hosting guide

I made a tutorial video that shows you how to integrate Amazon Simple Storage Service (s3) with A Small Orange web hosting for a grand total of less than $50 a year.  The software I used for Amazon S3 access in this video is CyberDuck for Mac OS X, however a cross-platform tool that is just as good is S3Fox for Mozilla Firefox.

Please feel free to ask any questions.  If anything is unclear, I’d be glad to help.  If you guys would like any more tutorial videos concerning this setup, just let me know.

Video requires Safari 4 to play in browser.
Direct link to video for download

Also available is a YouTube version of the video:

Amazon AWS is pretty awesome

After getting S3 setup, I am very happy with it.  Pay as you go service couldn’t get better than this.  It has some interesting “features” though, which are kind of weird.  I wanted to setup a static html index at the base of my S3 storage, but it doesn’t let you do that.  If you type in http://s3.cheesejaguar.com, then you get an access denied page.  However, if you type in http://s3.cheesejaguar.com/index.html then you go to the static page I wanted.  Small fun things like that, but I guess it’s aimed to prevent you from hosting dynamic HTML/PHP/CGI pages on S3, instead of using their Elastic Cloud Compute (EC2).  If I had more money, I’d definitely be playing around with EC2, but as it is it’s currently $70 a month for pay as you go.

Cheesejaguar.com is now in the cloud!

Well, sort of.  At least all static multimedia such as images, audio and video will now be hosted in the cloud.  It’s pretty awesome, and it’s pretty cheap.  I’m using Amazon’s S3, and using their bill calculator it should only be about 30-50 cents a month to host.  Pretty nifty and high tech, yes?

Eta Carinae

That image is hosted in the cloud.  Click for the 17 megapixel version.  I chose this image, because cloud computing gives me access to “infinite” data storage, kind of like the near-infinite expanse of space.  Of course I don’t have an infinite wallet, but still for what I’m doing it’s never going to cost more than a dollar a month.