Updated my s3 backup script to support MongoDB

Given my recent interest in MongoDB, I figured I should update my Ruby backup script to now support the exporting and backing up of MongoDB databases.

I've updated the code and placed the changes up in my Github account: simple-s3-backup.

2010-02-11 01:34PM — #mongodb #ruby #system administrationComments

Installing MongoDB on Ubuntu

There are already a few installation tutorials for getting MongoDB up and running on an Ubuntu server, but each either left a step or two out, or their suggested setup wasn’t what I was looking for, so I'm sharing my own tips. But, a few notes first:

  1. These instructions are how I installed MongoDB on Ubuntu 8.10 (Intrepid Ibex)
  2. Many of the tutorials out there recommend putting MongoDB in /opt/mongodb, but I chose /usr/local instead
  3. These instructions worked for me, and they probably will for you, but I can’t guarantee a thing

Initial user and directory setup

Before installing anything, I'm going to prepare some necessary directories and create the mongodb user:

sudo adduser mongodb
# for the mongodb data files:
sudo mkdir /var/lib/mongodb
# for the log files:
sudo mkdir /var/log/mongodb
sudo chown mongodb /var/lib/mongodb/

Install dependencies

Install the needed dependencies for building MongoDB from source:

sudo apt-get install curl tcsh scons g++ xulrunner-1.9-dev libpcre++-dev libboost-dev libmozjs-dev

Now, the Mozilla JavaScript libary. I normally install from my own temp directory (~/tmp), but download and compile from wherever you’re comfortable:

curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar zxvf js-1.7.0.tar.gz
cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
sudo JS_DIST=/usr make -f Makefile.ref export

Build MongoDB

We’ll use git to clone the source from their GitHub repository. I'm also going to compile the 1.2.2 release instead of the current HEAD. Again, get the source and build from whichever temp directory you’re comfortable with.

git clone git://github.com/mongodb/mongo.git
cd mongo
# checkout the 1.2.2 release for building
git checkout -b build r1.2.2
# build:
scons all
# install:
sudo scons --prefix=/usr/local install

Now, create the init.d script file to have MongoDB start up on a reboot.

sudo vi /etc/init.d/MongoDB
# my version of this script is here: http://gist.github.com/291349
# make init script executable:
sudo chmod +x /etc/init.d/MongoDB
# set up runtime links:
sudo update-rc.d MongoDB defaults

And to get it up and running, just run the init script:

sudo /etc/init.d/MongoDB start

If all the steps above went without any problems, then MongoDB should now be up and running on your Ubuntu server.

Here are some references that helped a lot in getting my own setup working:

Now, what I'm using MongoDB for will have to wait a day or so. :)

2010-01-31 08:34PM — #mongodb #ubuntuComments

A simple Ruby script for backing up files to Amazon S3

After reading about the troubles Jeff Atwood had with his host going down, I figured it was time I get a real backup process in place for my own data. Since my hosting is self-managed (at Slicehost) without any sort of attached official backup plan, I'm definitely vulnerable to any sort of server failure. I've had a near miss a couple of times with personal computers—which I now back up often—but I've yet to set up anything recurring for my hosted files.

So, I took some time over the weekend and wrote a simple backup script with Ruby that saves the archive files to Amazon S3. A while back I tried something similar using rsync, but at the time I stumbled on setting the SSH keys and all that up. Since I'm now using S3 to host images for The Tools Artists Use, adding another “bucket” to store some backups was a no-brainer.

The script works for me, and since it may be useful for others, I've put the code up on my Github account: simple-s3-backup.

2009-12-14 09:22PM — #ruby #system administrationComments

Weblog bankruptcy

Well, I did it. I killed the old weblog.

I didn’t just change weblog software (although I did do that, too), but I'm getting rid of all the old posts. Half of them are outdated and the rest were sort of useless. It want to start somewhat fresh again.

In a few days, I’ll have something a little more substantive on the big switch. Until then, welcome to the new brilliantcorners.org!

2009-11-25 01:14AM — #site newsComments