Affichage des articles dont le libellé est Linux. Afficher tous les articles
Affichage des articles dont le libellé est Linux. Afficher tous les articles

lundi 26 décembre 2011

Free MySQL backup with Dropbox

Recently, I've been working on creating an automatic service for backing up our RedmineMySQL database on the Debian server.


So I've decide to share there how I made a free backup service for the MySQL database.
I set several goals that should be attempted in order to consider that backup service is useful

  1. Only free & open source applications.
  2. Remote disk storage also for free.
  3. Backup must be automatic.
  4. Backup encryption.
To accomplish these requirements finally I have selected the next tools:
  1. AutoMysqlBackup - http://sourceforge.net/projects/automysqlbackup - the core of theservice.
  2. DropBox free account (2 Gb for free) - www.dropbox.com
  3. crontab - a standard Linux job automation tool
  4. openssl - for encryptionHow does this it works together.A little description.
First of all you will be need a DropBox account - there your MySQL backups will arrive and willbe stored. You have to download the DropBox client application or a DropBox daemon. I suggest you to use a dropboxd (daemon) for the server use:

https://www.dropbox.com/install?os=lnx - install DropBox as a daemon

Downlaod & install AutoMysqlBackup tool. After the installation you have to modify the script /etc/automysqlbackup/automysqlbackup.conf

You should uncomment the line you need and put the appropriate values. Each line in this script is well documented and you will find all the options you need. Just a brief description of what can you configure with it : mysql server address, mysql credentials for the command mysqldump, location where the dump will be stored, the regularity of the backuping, etc.

Next step, is creating your own bash script that will be called by cron, make a backup with autoMysqlBackup, copy the backup files into the local dropBox folder.

Download my example : http://dl.dropbox.com/u/3839545/backup.sh

Make sure that your own backup.sh is runnable (don't forget chmod u+x backup.sh)

The next step is to configure your crontab. In the crontab I've defined the period of time the script backup.sh will be called. I set up the backup everyday at 3:00 AM.
Make sure you have the root privileges and run the following command :
crontab -e
and at the end of the file add the line :
00 03 * * * /root/backup.sh

And the last step is about the encryption. The openSSL encryption is made by the AutoMysqlBackup, for this you have to uncomment in your /etc/automysqlbackup/automysqlbackup.conf the following line:
CONFIG_encrypt='yes'
don't forget to set the password to encrypt!

That's all, make a test that prove that your backup is working fine before moving all this stuff in the production environment.

samedi 13 septembre 2008

Des espaces à la fin des noms. Version Windows et Linux

Bonjour,

Est-ce que vous savez que les règles du nommage des fichiers sont très dépendantes du système d’exploitation. Voilà un exemple qui m’a coûté quelques jours d’investigation pour un projet sur lequel je travaille.

Sous Windows le nom du fichier ne peut pas contenir des espaces à la fin! Pour Windows les fichies :
1. ‘toto.txt’
2. ‘toto.txt ’ (un espace à la fin)
3. ‘toto.txt ‘ (deux espaces à la fin)
sont identiques et seront représentez par UN SEUL fichier sur votre disque ! Windows va tronquer les espaces à la fin.

Dans les OS comme Linux RedHat ce n’est pas le cas. Pour ce système, ces trois fichiers sont les fichiers différents. Donc, pour Linux l’espace à la fin du nom de fichier est tout à fait légitime.

Cette différence subtile m’a coûté 2 jours pour réussir à reproduire une anomalie. Vu que notre plateforme de développement est sous Windows et les serveurs de production sont sous Linux, je ne pouvais pas avoir le même comportement de l'application que nos clients.

Conclusion. La reproduction des anomalies, les tests de régression, les tests unitaires doivent être exécutés dans l’environnement le plus proche possible de votre environnement de production. C’est une règle de-facto de développement que je n’ai pas respecté. Mais, l’anomalie est reproduite et sera corrigé et moi, j’ai appris quelque-chose de nouveau et c’est ça qui compte !