Backing Up and Migrating Chevereto Docker Service (4.0.6)
To back up and migrate a Chevereto Docker service, follow these steps:
- Stop the running Chevereto container with:
docker stop chevereto- 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 thetarcommand to create a backup. For example, run the following command to back up theimagesdirectory to the current path:
tar -zcvf images_backup.tar.gz /var/www/html/images/- Export the database with:
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sqlHere, CONTAINER is the name or ID of the Chevereto container, and DATABASE is the database name used by Chevereto.
-
Copy the backup archive and the exported database file to the new VPS.
-
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:
sudo apt-get updatesudo apt-get install docker-compose docker.io- Create a new directory on the new VPS. For convenience, you can name it
Chevereto, then switch into that directory with:
mkdir Cheveretocd Chevereto- In the
Cheveretodirectory, create a newdocker-compose.ymlfile 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:
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=cheveretoMake sure the docker-compose.yml file is located in the root of the Chevereto directory so that subsequent commands work properly.
- Start the Chevereto service on the new VPS with:
docker-compose up -dThis 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.