Backup Manager (GNU/Linux)

Requirements:
  • You have an account at console.online.net
  • You have a Dedibox dedicated server
  • You have configured the Dedibackup account in your management console

Backup Manager is a software that you can use to automate the backups of your server on the Dedibackup FTP space.

Requirements

  • Have a GNU/Linux distribution
  • Have gettext and Perl installed

Installation of Backup Manager

apt-get install backup-manager

Configuration of Backup Manager

Edit the file /etc/backup-manager.conf while logged in as root

root@dedibox:/home/bertrand# nano /etc/backup-manager.conf
...

Following the most common options :

Name of the option Example of the value Description
Local storage
BM_REPOSITORY_ROOT “/var/archives” Local folder to store the archives
BM_ARCHIVE_TTL “3” Number of archives to be stored locally
BM_ARCHIVE_METHOD “tarball-incremental mysql svn” Archive method to be used. Can be one or several of these value: tarball, tarball-incremental, mysql and svn
Elements to archive
BM_TARBALL_DIRECTORIES “/etc /home” List of the folders to backup
BM_TARBALL_BLACKLIST “/var/archives /home/notbackup” Sub-folders to be eventually excluded
Transfer to the remote storage
BM_UPLOAD_METHOD “ftp” Method to transfer the backups
BM_UPLOAD_FTP_USER “sd-000” Identify to be used for the FTP server
BM_UPLOAD_FTP_PASSWORD “mYp4SsW0rd” Password for the previously specified user
BM_UPLOAD_FTP_HOSTS “dedibackup.dedibox.fr” Name of the FTP server
BM_UPLOAD_FTP_PASSIVE “true” Activate the passive transfer mode
BM_UPLOAD_FTP_PURGE “true” Delete the directory contents before transferring (true or false)
BM_UPLOAD_FTP_DESTINATION “/” Destination folder for the files to be copied (ATTENTION: It has already to exist on the server)
Incremental archiving
BM_TARBALLINC_MASTERDATETYPE “monthly” Frequency of the creation of the complete archive. Can be daily (daily) or monthly (monthly)
BM_TARBALLINC_MASTERDATEVALUE “23” Day of the creation of the complete archive (from 1 (Monday) to 7 (Sunday) for daily backups and from 1 to 31 for monthly ones)
MySQL Database
BM_MYSQL_DATABASES “mysql” Name of the MySQL database
BM_MYSQL_ADMINLOGIN “root” Identifier to use for connecting to the MySQL server
BM_MYSQL_ADMINPASS “” Password associated to the previously specified identifier
BM_MYSQL_HOST “localhost” Name of the MySQL server
BM_MYSQL_PORT “3306” Listening port of the MySQL server
BM_MYSQL_FILETYPE “gzip” Compression format of the backup archive (gzip or bzip2)
SVN server
BM_SVN_REPOSITORIES “” Absolute path for SVN
BM_SVN_COMPRESSWITH “gzip” Compression format for the SVN backup (gzip or bzip2)
Advanced
BM_PRE_BACKUP_COMMAND “” Allows to execute a script before launching Manager
BM_POST_BACKUP_COMMAND “” Allows to execute a script after the last action of Backup Manager

For more information about the other configuration options, we refer to the Official documentation.

Automatization of backups

To automatize the backup of our server, we use a small script together with cron.

  • Creation of the script

Copy/paste the following in your shell:

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
  • Add it to cron using crontab
root@dedibox:~# crontab -e

Add the following line to run the Backup Manager…

…each 15 days at 8:04

4 8 */15 * * /etc/backup-manager.sh

…on February, 4th at 23:16

16 23 4 2 * /etc/backup-manager.sh

…from Monday to Friday at 8:04

4 8 * * 1-5 /etc/backup-manager.sh

Recovery of backups

  • You only need to connect to the server dedibackup.dedibox.fr.
bertrand@dedibox:~$ ftp -n dedibackup.dedibox.fr
Connected to dedibackup.dedibox.fr.
220-FTP server ready.
220 Ceci est un systeme prive - Aucun utilisateur anonyme autorise
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> user sd-000 mYp4SsW0rd
331 Utilisateur sd-000 OK. Veuillez taper votre mot de passe
230-L'utilisateur sd-000 a un acces de groupe sur:  1000     106      105
230- 104      46       44       30       29       25       24       20
230- 4
230-OK. Le repertoire restreint courant est /
230 3597 Ko utilises (0%) - autorises : 10240000 Ko
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 Commande PORT executee
150 Connexion au port 32845
drwxr-xr-x    2 1000     1000          216 May 31 19:36 .
drwxr-xr-x    2 1000     1000          216 May 31 19:36 ..
-rw-------    1 1000     1000           10 May 31 19:36 .ftpquota
-rw-r--r--    1 1000     1000          123 May 31 19:36 dedibox-20060531.md5
-rw-r--r--    1 1000     1000       289778 May 31 19:36 dedibox-etc.20060531.tar.gz
-rw-r--r--    1 1000     1000      3393717 May 31 19:36 dedibox-home.20060531.tar.gz
226-Options: -a -l
226 6 elements au total
ftp> get dedibox-etc.20060531.tar.gz
local: dedibox-etc.20060531.tar.gz remote: dedibox-etc.20060531.tar.gz
200 Commande PORT executee
150-Connexion au port 32846
150 283.0 Koctets a downloader
226-Fichier transfere sans probleme
226 0.021 secondes (mesuree ici), 12.87 Moctets par seconde
289778 bytes received in 0.03 secs (9793.3 kB/s)
ftp> bye
221-Au revoir. Vous avez uploade 0 et downloade 283 Koctets.
221 Deloggue.
  • Check if the file is downloaded:
bertrand@dedibox:~$ ls
dedibox-etc.20060531.tar.gz
  • Decompress the archieve
bertrand@dedibox:~$ tar -xvzf dedibox-etc.20060531.tar.gz
etc/
etc/apm/
etc/apm/resume.d/
...
etc/profile
etc/mime.types
etc/bash_completion
  • From now on we can restore the files that we want. For example…
bertrand@dedibox:~$ sudo mv /etc/network/interfaces /etc/network/interfaces.old
bertrand@dedibox:~$ sudo mv etc/network/interfaces /etc/network/interfaces

References

- The Backup Manager script is available here