362 字
2 分钟

Backing Up and Migrating Chevereto Docker Service (4.0.6)

To back up and migrate a Chevereto Docker service, follow these steps:

  1. Stop the running Chevereto container with:
Terminal window
docker stop chevereto
  1. Back up the /var/www/html/images/ directory. Different VPS providers may offer different backup and migration methods. If you are using a Linux-based VPS, you can use the tar command to create a backup. For example, run the following command to back up the images directory to the current path:
Terminal window
tar -zcvf images_backup.tar.gz /var/www/html/images/
  1. Export the database with:
Terminal window
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

Here, CONTAINER is the name or ID of the Chevereto container, and DATABASE is the database name used by Chevereto.

  1. Copy the backup archive and the exported database file to the new VPS.

  2. Install Docker and Docker Compose on the new VPS. If they are not installed yet, follow the official installation guide for your operating system. For example, on Ubuntu 20.04 you can install them as follows:

Terminal window
sudo apt-get update
sudo apt-get install docker-compose docker.io
  1. Create a new directory on the new VPS. For convenience, you can name it Chevereto, then switch into that directory with:
Terminal window
mkdir Chevereto
cd Chevereto
  1. In the Chevereto directory, create a new docker-compose.yml file to start the Chevereto service. To ensure the service starts correctly, make sure to set the following environment variables to match your original Chevereto deployment:
  • CHEVERETO_DB_HOST: Database host address.

  • CHEVERETO_DB_USER: Username used to connect to the database.

  • CHEVERETO_DB_PASS: Password used to connect to the database.

  • CHEVERETO_DB_NAME: Database name used by Chevereto.

  • CHEVERETO_ASSET_STORAGE_BUCKET: Path where image files are stored.

The docker-compose.yml file should look like this:

Terminal window
version: '3'
services:
chevereto:
image: ghcr.io/chevereto/chevereto:latest
container_name: chevereto
ports:
- "80:80"
environment:
- CHEVERETO_DB_HOST=database
- CHEVERETO_DB_USER=chevereto
- CHEVERETO_DB_PASS=user_database_password
- CHEVERETO_DB_NAME=chevereto
- CHEVERETO_ASSET_STORAGE_TYPE=local
- CHEVERETO_ASSET_STORAGE_URL=/images/_assets/
- CHEVERETO_ASSET_STORAGE_BUCKET=/var/www/html/images/_assets/
volumes:
- /var/www/html/images:/var/www/html/images
depends_on:
- database
database:
image: ghcr.io/chevereto/chevereto-mariadb:latest
container_name: chevereto_database
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=chevereto

Make sure the docker-compose.yml file is located in the root of the Chevereto directory so that subsequent commands work properly.

  1. Start the Chevereto service on the new VPS with:
Terminal window
docker-compose up -d

This will start the Chevereto service on the new VPS, connect to the restored database, and read from the backup directory according to the environment variable configuration. After that, you can access the new VPS IP address or domain name in your browser to verify that Chevereto is working correctly.

Backing Up and Migrating Chevereto Docker Service (4.0.6)
https://catcat.blog/en/chevereto-docker-backup.html
作者
猫猫博客
发布于
2023-04-11
许可协议
CC BY-NC-SA 4.0