Backup Manager


Backing up MariaDB databases on Debian

Long before settling on rdiff-backup and restic, Backup Manager was my main backup program. That was circa 2007. I revisited my old favourite recently because I needed a tool to archive MariaDB databases.

Backup Manager is a command line utility capable of archiving different types of data. You can deploy it for backing up files, PostgreSQL databases, MySQL databases and Subversion repositories.

There are a few characteristics which differentiate Backup Manager from many other backup programs. Native commands, native archive formats and restore functionality are absent.

A collection of Bash and Perl scripts, Backup Manager relies on a number of widely common tools such as tar, mysqldump, gzip, and bzip2 to build archives.

Lack of native archive formats makes Backup Manager redundant for data recovery. In practice, you will restore archives by running the same tools they were generated with.

Environment

  • Platform: Debian GNU/Linux 10
  • Package: backup-manager 0.7.14–1

Installation

Backup Manager is currently hosted on github but is also available from Debian main software repositories. We will install the Debian package.

The installation process expects you to specify backup source and destination directories. Accept the defaults for the time being.

apt install backup-manager

Configuration

1. Create backup user

Dumping databases requires an authorised user with certain global privileges. Using all-powerful root is not a good security practice. It makes better sense to assign the task to a dedicated new user.

Please note the account permissions in the grant statement below do not necessarily required by all systems. You should review the SQL command closely and leave in only those privileges applicable to your environment.

You need to provide your own credentials to replace <user> and <password> before logging in to the database server.

CREATE USER `<user>`@`localhost` IDENTIFIED BY '<password>';
GRANT SELECT, RELOAD, stage, SHOW VIEW, EVENT, TRIGGER, REPLICATION CLIENT ON *.* TO '<user>'@`localhost`;
FLUSH PRIVILEGES;

2. Reconfigure Backup Manager

Backup Manager divides the backup process into three distinct stages: build, burn and upload. Out of the box, all are active but you can disable them individually.

Each stage is further subdivided into various methods. A method is a function which performs a particular task. The DVD-RW burning method, for example, is tasked with writing archives to a re-writable DVD.

Begin with editing the default configuration file /etc/backup-manager.conf.

# Personal preference: Where to store the archives
# Directory will be created if it doesn't exist
export BM_REPOSITORY_ROOT="/backup/backup-manager/mariadb"

# Personal preference: Number of days we have to keep an archive
export BM_ARCHIVE_TTL="28"

# The backup method to use
export BM_ARCHIVE_METHOD="mysql"

# The user who is allowed to dump databases
export BM_MYSQL_ADMINLOGIN="<user>"

# User's password - leave blank
export BM_MYSQL_ADMINPASS=""

# Extra options to append to mysqldump
export BM_MYSQL_EXTRA_OPTIONS="--single-transaction"

# Specify DBs to exclude here (separated by space) 
export BM_MYSQL_DBEXCLUDE="information_schema performance_schema"

# We are keeping archives locally
export BM_UPLOAD_METHOD="none"

# We don't require optical media storage
export BM_BURNING_METHOD="none"

3. Set backup user password

All configuration parameters are set so far except for the backup user password. The BM_MYSQL_ADMINPASS setting was left blank intentionally since we have the option of storing it safely at another location.

Backup Manager has implemented a MariaDB server feature which allows clients to use their own option file. The implementation in not full since it seems to support user passwords only.

Create and populate the default option file /root/.backup-manager_my.cnf.

[client]
password="<password>"

Finish configuration by securing the new file.

chmod 0600 /root/.backup-manager_my.cnf

Verification

Run Backup Manger from command line as root and examine all the output. The messages display useful information about normal operations in addition to any warnings and errors.

backup-manager -v

Automation

The installation package provides a template to automate the backup process under cron. The install command will copy the template as a daily job and sets its permissions.

install -m 0700 /usr/share/backup-manager/backup-manager.cron.tpl /etc/cron.daily/backup-manager

What next…

Backup Manager is a versatile program. Here are some suggestions in case you want to discover more:

  • Upload archives to remote locations including Amazon S3
  • Add another backup method to archive both files and database
  • Write your own scripts to run before and after the backup process

The configuration file is a good place to explore Backup Manager capabilities. You can also visit the wiki or install backup-manager_doc package but keep in mind some parts of the documentation are out of date.