Nicolas Alpi

Hi, Salut

Pragmatic web application developer, I enjoy my freelance way of life in my home office every day. I mainly use Ruby based frameworks (Rails / Sinatra / Rack) as my main development arsenal and jQuery is my day to day friend for every piece of client side. Aside from development freedom, I really enjoy the business side of behind freelance, and will soon to release my own personal application. In my free time, I enjoy cooking, runnning and sharing a coffee or a beer with people, so if you're around Bristol, let's be in touch.


Starting with backup-manager, or how to never loose data again!

Loosing data can be quite ... annoying.

The last thing you want is to have a disaster on your server and being unable to recover your data.
I run all my projects and different blogs on one server, hosted by OVH. So I have multiple databases, gems, websites and configurations that I want to backup.
Hopefully, OVH provide with every dedicated server an external FTP server dedicated to backups.
So I’ve installed backup-manager and make it runs twice a day.

Warning

Because backup-manager compress your files into archives, it will cost you some space on the disk, so be sure to change the default value of the target and do your backup on a proper partition.
If you don’t, backup-manager will do the backups in / by default, so when it’ll be full, your sever will not work properly.

Installation

sudo apt-get install backup-manager

Tweacking

Installation create a default config file. You’ll need to edit it to match you configuration.

sudo vim /etc/backup-manager.conf

Before I explain you my config file, here is how I’ve config my server:

So basically, want I want is:

I save my /home/, /etc/, /opt/, all my databases to an external partition then an external FTP.

In backup-manager.conf, you’ll need to set:

Local Storage

Backup directories

Backup transfer

Incremental Archives (set BM_ARCHIVE_METHOD = tarball-incremental)

Mysql databases

Others

Pratical Backups

Databases

Please be careful, as you’ll need to write in this file the login and password of a user to procede to dabases backups.
Don’t use root!, neither an existing user. You’re going to create a new user, with limited right on databases and tables, and you’ll protect the backup manager config file.

mysql -u root -p
GRANT SHOW DATABASES,SELECT,LOCK TABLES ON *.* TO 'backupuser'@'localhost' IDENTIFIED BY 'secretpassword';
exit;
sudo chown root:root /etc/backup-manager.conf
sudo chmod 640 /etc/backup-manager.conf

Now you can set the 2 values in the backup-manager config file.

BM_MYSQL_FILETYPE

Mysql database compression after dump.

Make sure that bzip2 is intalled

sudo apt-get install bzip2

BM_POST_BACKUP_COMMAND

Execute a command once bakcup done. You can,for example, use this to send an email after the backup.

Automated backups

You can use cron to schedule your backups. Before just create a little script

cat << EOF > /etc/backup-manager.sh && chmod 700 /etc/backup-manager.sh
#!/bin/sh
test -x /usr/sbin/backup-manager || exit 0
/usr/sbin/backup-manager
EOF

And now you can add this script to your contab

crontab -e

And add

1 0 * * * /etc/backup-manager.sh

Here is ubuntu cron doc, easy to understand (https://help.ubuntu.com/community/CronHowto)

Do more

For example, you can call backup-manager with backup-manager -c /path/to/configfile and by this way, having 2 crons. One running every days, executing backups of files and db, and another one, in the middle of the day, only for the db ;).

You can do much more than these options (cd/dvd burning for example), please be sure you read the complete wiki at http://wiki.backup-manager.org/index.php/Main_Page#Documentation


Comments

blog comments powered by Disqus