Docker Tutorial: Backing Up and Restoring MySQL and WordPress in Docker




In this video we’ll cover how to backup files from your docker container as well as a MySQL database. This is done with an installation of WordPress.

Original source


11 responses to “Docker Tutorial: Backing Up and Restoring MySQL and WordPress in Docker”

  1. Excellent tutorial, This is all I needed to create a new wordpress from existing wordpress container. I like the simple approach; no fancy tools are involved. Of-course it can be automate using tools like Ansible or similar. Thanks again 🙂

  2. Hey
    Im currently getting rather nuts since im trying to get this thing in to a cronjob:
    shouldn't it be something like:
    docker run –rm -v $(pwd):/backups/ –link=mywrodpress_db_1:dz mysql /usr/bin/mysqldump –host$DZ_PORT_3306_TCP_ADDR -uroot -psecret wordpress > /backups/wordpress.sql

    I have seen other people doing it with already fixed containers but now im to stubborn…

    I can't get it to use my DZ_PORT_3306_TCP_ADDR variabel…
    How do get it to use it's own variabel?
    Since it's already linked i shouldn't have to define a -e DZ_PORT_3306_TCP_ADDR, half the point is to use the linked one ^^

  3. For scripting reasons I'd lean on the "exec" option. For a mysql dump from your host just run something like
    docker exec wpfig_db_1 mysqldump –all-databases –password=secret > /backups/wordpress.sql
    Should result in you having your .sql file where you expect it 🙂 Keep up the vid's they're a great help!

  4. Would it be possible to map the file system to some container that supports incremental file system (preventing possible issues that could arrise if a user is working on the WP environment, between the dumping of the sql and the backup of the files)?

  5.  It would be great if you could show us a diagram like on the "Setting Up a WordPress Site Using Docker" that diagram really helped. It is a little difficult to mentally map what you are doing ( going in to container, exporting mysql, sharing volumes…)

Leave a Reply