简体   繁体   中英

How to backup dockerized wordpress on linode?

I deployed wordpress to linode using docker-compose for my friend and everythings have worked well for 3 months. But now my friend want to stop linode and i need to backup everything back to local machine.

My wp site is just a simple blog. I deployed 3 services by docker-compose which are wordpress, mysql, php_myadmin. Here is my docker-compose.yaml file:

version: "3.0"
services:
  mysqlwp:
    container_name: mysqlwp
    image: mysql:5
    environment:
      - MYSQL_ROOT_PASSWORD=${PASSWORD}
      - MYSQL_DATABASE=${DATABASE}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${PASSWORD}
    restart: always
    #Mount database
    volumes:
      - '${MYSQL_DATA_DIR}:/var/lib/mysql'
  wordpress:
    container_name: wordpress
    image: wordpress:latest
    environment:
      - WORDPRESS_DB_NAME=${DATABASE}
      - WORDPRESS_DB_USER=${DB_USER}
      - WORDPRESS_DB_PASSWORD=${PASSWORD}
    ports:
      - '80:80'
    links:
      - 'mysqlwp:mysql'
    depends_on:
      - 'mysqlwp'
    #Mount source code
    volumes:
      - '${SOURCE_CODE_DIR}:/var/www/html'
    restart: always
  phpMyAdmin:
    container_name: phpMyAdmin
    image: phpmyadmin/phpmyadmin
    links:
      - 'mysqlwp:mysql'
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=mysqlwp
    depends_on:
      - 'mysqlwp'
    ports:
      - '8888:80'
    restart: always

I am not an expert in wordpress and docker, im just learning them forward. I found a ton of plugins of wordpress that help me backup but i am not familiar with them and not sure that what should i pick?

Should i just backup all the images and database? How should organize them well for the next relaunch?

Since you map ${SOURCE_CODE_DIR} to /var/www/html and ${MYSQL_DATA_DIR} to /var/lib/mysql , you should create a backup of the ${SOURCE_CODE_DIR} and ${MYSQL_DATA_DIR} which are stored on the host machine.

It's the whole of your data, other data are temporary and related to the images and docker. If you're looking for creating some backup of the images, you should look for the following topics:

  • docker save... command.
  • docker load... command.

Related sources:

  1. docker save
  2. docker load
  3. Docker import/export vs. load/save

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM