How to Backup & Restore Apache Answer (Self-Hosted) with MariaDB
Hi there! I’m Maneshwar. Right now, I’m building LiveAPI, a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.
Whether you’re migrating your Apache Answer instance to a new server or just playing it safe with backups, this guide walks you through backing up, purging, and restoring data — without breaking the Answer UI or your sanity.
Prerequisites
- Docker installed and running.
- MariaDB or MySQL set up (port
3306
open). - Access to your Answer container or Docker build.
- SSH access to both source and target servers if migrating.
Step-by-Step Guide
Build & Run the Answer Image
Clone and build the Docker image:
git clone https://github.com/apache/answer
cd answer
docker build -t answer:latest .
Run it:
docker run -d -p 9080:80 -v answer-data:/data --name answer answer:latest
This mounts
/data
inside the container for uploads, cache, etc.
Create a MariaDB User and Empty Database
Connect to your MariaDB instance:
DROP DATABASE IF EXISTS `dev-answer`;
CREATE DATABASE `dev-answer`;
GRANT ALL PRIVILEGES ON `dev-answer`.* TO 'dev-answer'@'%' IDENTIFIED BY 'pass123';
FLUSH PRIVILEGES;
Backup Your Answer Data
You can dump the whole DB like this:
mysqldump -u dev-answer -p pass123 -h 127.0.0.1 -P 3306 dev-answer > backup.sql
Or directly stream into another DB:
mysqldump -u dev-answer -p pass123 -h 127.0.0.1 -P 3306 dev-answer
| mysql -u dev-answer -p pass123 -h <TARGET-IP> -P 3306 dev-answer
Restore Without Overwriting the Config Table
The config
table holds runtime settings, so you might want to exclude it.
mysqldump --no-create-info --ignore-table=dev-answer.config
-u dev-answer -p pass123 -h 127.0.0.1 -P 3306 dev-answer
| mysql -u dev-answer -p pass123 -h <TARGET-IP> -P 3306 dev-answer
Purge All Data Except Config (Before Restoring)
If you’re restoring on a dirty DB, clean everything except config
:
SET FOREIGN_KEY_CHECKS=0;
-- Generate TRUNCATE commands:
SELECT CONCAT('TRUNCATE TABLE `', table_name, '`;')
FROM information_schema.tables
WHERE table_schema = 'dev-answer' AND table_name != 'config';
SET FOREIGN_KEY_CHECKS=1;
Repeatable Restore (All Data Including Config)
If you do want to restore everything, even config:
mysqldump --no-create-info
-u dev-answer -p pass123 -h 127.0.0.1 -P 3306 dev-answer
| mysql -u dev-answer -p pass123 -h <TARGET-IP> -P 3306 dev-answer
Pro Tips
-
--no-create-info
: prevents table structure from being overwritten. -
--ignore-table=dev-answer.config
: keeps your runtime config safe. - Use
-P 3306
only if you’re not using a socket connection.
Final Sanity Check
After restoring:
- Visit the Answer web UI → ensure questions, tags, users load.
- Check
/data/uploads/
volume if you were using it (copy it if needed). -
answer config
CLI should not reset or log any cache errors.
Summary
With a few mysqldump
and Docker incantations, you can fully back up and restore your Apache Answer setup, including optional selective table syncing. Great for:
- Server migration
- Disaster recovery
- Periodic data sync between prod/staging
LiveAPI helps you get all your backend APIs documented in a few minutes.
With LiveAPI, you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.
If you’re tired of updating Swagger manually or syncing Postman collections, give it a shot.