Backup from Docker install Help

I’ve installed invoice ninja via docker, and after some teething issues, everything is working.

Does anyone know, what the procedure is for making backups? ideally, I’d want to backup all client, quotes, payments, and invoice, etc aswell as the customised invoice design/settings.

What approach did you take to storing your container’s data (internal docker volumes, or external binding)? You’ll have to back that up and then the mysql database using something like mysqldump - include the docker-compose.yml and associated files and you have pretty much everything.

Hey there. As far as I know, we don’t have any official way to do this, yet.

@david @hillel What about export DB button in AP?

At the moment, approach with mysqldump is by far easiest way.

Hi Both,

So, I’m using the internal docker volumes, so I can use standard tools to take a backup of these.

In terms of the mysqldump, how would I run this as the db is part of the docker-compose environment. I’m guessing get a /bin/bash shell within the container, then take a backup using mysqldump then?

Restoring would be in reverse I assume?

The Mysql container is /bin/sh

Yea, the mysqldump is standard stuff. I’m sure there are ways to automate that (though getting a cron running in containers is not always fun).

What “standard tools” would you use to backup you internal docker volumes?

Basically using this tutorial:

Hello everyone,
i am a new user of Invoice Ninja but wanted to help out here. I was able to backup and restore (migrate) my environment between 2 different hosts.

This is documented in docker’s website but it would be great if Developers would confirm my steps.

To backup App & DB containers i used these 2 commands, it backup the database and all data:

docker run --rm --volumes-from dockerfiles_db_1 -v $(pwd):/tmp/backup mysql:5 tar cvf /tmp/zkd/backup-db.tar /var/lib/mysql
docker run --rm --volumes-from dockerfiles_app_1 -v $(pwd):/tmp/backup alpine tar cvf /tmp/temp/backup-app.tar /var/www/app/storage

Than on new host i followed the installation procedure on github:, once new blank containers were up i run these commands to restore the data. Of course i copied backup files to the temp folder

docker run --rm --volumes-from dockerfiles_db_1 -v $(pwd):/tmp mysql:5 bash -c "cd /var/lib/mysql && tar xvf /tmp/backup-db.tar --strip 1"
docker run --rm --volumes-from dockerfiles_app_1 -v $(pwd):/tmp alpine sh -c "cd /var/www/app/storage && tar xvf /tmp/backup-app.tar --strip 1"

All of my data appeared on the new host

I hope this helps and here is the link for docker’s official documentation : Use volumes | Docker Documentation

1 Like