Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Backing up Docker Data

23 Feb 2020 » docker, backup, production, aws, projectbox

I need to get off of AWS’s infrastructure. AWS costs $30 a month for a shitty 1cpu 1gb ram 30 gb disk box. If you asked me, I think that is crap and way over priced. I don’t use even half of their services.

Backups

Well it’s great because I just decided to run docker and make it very moveable infrastructure.

Backing up docker database:

docker exec -it kanboard_db_1 /bin/sh

# From the container
mysqldump -u kb kanboard -p > kb.sql

# From the host
docker cp kanboard_db_1:/kb.sql ./kb.sql

And just like that I had my database..

As for my volumes, there was a different story.

Docker Volumes

This was tricky for me. For most of my containers where I specified a volume, I had no problem transferring data. As for the containers I didn’t specify a volume for, I was in some trouble and most sysadmins would be disappointed in my work..

It only happened for the kanboard container which was mostly plugins, but I ended up continuing to get the same permissions issues. Unless I ran the command prefixed with sudo I would get the following results:

[ec2-user@ip-172-31-15-194 ~]$ ls /var/lib/docker/volumes/6634d35054b6f70fe46404d15dec4dc38e740f2b93935b02a1e40d01f3c32a6a
ls: cannot access /var/lib/docker/volumes/6634d35054b6f70fe46404d15dec4dc38e740f2b93935b02a1e40d01f3c32a6a: Permission denied
[ec2-user@ip-172-31-15-194 ~]$

I ran into 0 errors when using sudo, as for running the commands as a normal user I got the results above. So I did what any rational impatient person would do and I ran the following:

sudo cp /var/lib/docker/vol-hash ~/volume-data

sudo chmod 777 ~/volume-data

I did this for the three volumes that were passed to the docker container, specifically kanboard_data, kanboard_plugins and kanboard_ssl.

I was then able to scp the files down to my local server where I am replicating the docker services.

© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT