Skip to main content

Backing up databases inside docker containers

November 1, 2021

We recently posted a guide to get up and running with the great backup tool Kopia and received a question asking if it was possible to use the Kopia installation on the host to back up container databases as well.

The answer is yes! Just use docker exec and mysqldump to export the database to the host filesystem as a sql file.

The example below is similar to a command that we run as a cron job each night. The name of the container is mariadb, and $MYSQL_ROOT_PASSWORD is an environment variable that exists within the container. The exact command may not work right off the bat on your system, but it should get you most of the way there.

docker exec mariadb sh -c \ 'mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > /root/db/mariadb.sql

Why FTL?

Traditional Host
FTL

Inexpensive Monthly Plan

Our entry rate of $20 per site includes all of the features below with no long term commitment. We don't believe in providing less for less.

High Performance Servers

With AMD EPYC processors, RAID 10 NVMe SSDs, cutting edge software, and a 10 Gbit network connection, there's no need to limit visits, bandwidth, or files.

Fully Managed by Developers

We take care of all the technical stuff so you can focus on your website. And support is always free.

PageSpeed & SEO Optimization

As part of the migration process we work directly on your website to increase performance and ensure SEO best practices.

Reliable Daily Backups

Encrypted snapshots of your files and databases stored in the cloud, plus local redundancy via RAID 10. Our backups are not deleted after a month.

Top Notch Security

Reduce the risk of hacks and downtime with SSL, HSTS, DDoS / bot protection, containerization, and secure tunneling. Our servers have no open ingress ports.

Global Edge Caching & CDN

We leverage Cloudflare's global network of 250 edge nodes in 100+ countries, so you can reach 95% of the world's population within the blink of an eye.

Smart Image Optimization

New images are scanned daily and optimized using libvips. Wordpress sites get our custom libvips plugin to dramatically increase image processing speed.

Active Uptime Monitoring

If your website goes down, we'll know before you do. And if a server problem causes uptime to drop below 99.9% in any given month, you won't get billed.

Money Back Guarantee

If you're not satisfied with our service during the first 60 days, we'll refund all payments and help migrate your site to another provider.