Skip to content

Instantly share code, notes, and snippets.

Forked from Meldiron/
Created April 27, 2022 07:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Evgentret/5a04f59c99371b63c1fc5dfd74920a4f to your computer and use it in GitHub Desktop.
Save Evgentret/5a04f59c99371b63c1fc5dfd74920a4f to your computer and use it in GitHub Desktop.
Backup and Restore Appwrite, the lazy way 🐌
# Make sure to stop Appwrite before this backup,
# and make sure you have enough space on the machine.
# After backing up, make sure there is a file in 'backups/backup-___.tar.gz'.
# Also please check size of this file, it should be at least 5kb, even for small instances.
docker run --rm \
-v appwrite_appwrite-mariadb:/backup/appwrite-mariadb \
-v appwrite_appwrite-redis:/backup/appwrite-redis \
-v appwrite_appwrite-cache:/backup/appwrite-cache \
-v appwrite_appwrite-uploads:/backup/appwrite-uploads \
-v appwrite_appwrite-certificates:/backup/appwrite-certificates \
-v appwrite_appwrite-functions:/backup/appwrite-functions \
-v appwrite_appwrite-influxdb:/backup/appwrite-influxdb \
-v appwrite_appwrite-config:/backup/appwrite-config \
-v appwrite_appwrite-builds:/backup/appwrite-builds \
-v $(pwd)/.env:/backup/appwrite/.env \
-v $(pwd)/docker-compose.yml:/backup/appwrite/docker-compose.yml \
-v $(pwd)/backups:/archive \
--env BACKUP_FILENAME="backup-%Y-%m-%dT%H-%M-%S.tar.gz" \
--entrypoint backup \
# Contributors:
# - Matej Bačo (Meldiron):
# - AidsMcGhee:
# Make sure the Appwrite did NOT run on this server previously,
# and make sure to stop it before this restore.
# If appwrite ran here already, make sure to
# stop Appwrite with 'docker-compose down -v', and ideally
# also remove appwrite folder.
# Before running, be in any directory,
# but make sure 'backup.tar.gz' file with your backup is in there.
# Whichever directory you are in, this script will create 'appwrite'
# folder in here, with a configuration from backup.
# Backup script puts date in the file name, make sure to
# rename file to exactly 'backup.tar.gz'.
# After restore, you can enter appwite folder 'cd appwrite'
# and start Appwrite with 'docker-compose up -d'.
# Untar backup
tar -C /tmp -xvf backup.tar.gz
# Restore volumes and configuration
docker run -d --name temp_restore_container \
-v appwrite_appwrite-mariadb:/backup_restore/appwrite-mariadb \
-v appwrite_appwrite-redis:/backup_restore/appwrite-redis \
-v appwrite_appwrite-cache:/backup_restore/appwrite-cache \
-v appwrite_appwrite-uploads:/backup_restore/appwrite-uploads \
-v appwrite_appwrite-certificates:/backup_restore/appwrite-certificates \
-v appwrite_appwrite-functions:/backup_restore/appwrite-functions \
-v appwrite_appwrite-influxdb:/backup_restore/appwrite-influxdb \
-v appwrite_appwrite-config:/backup_restore/appwrite-config \
-v appwrite_appwrite-builds:/backup_restore/appwrite-builds \
-v $(pwd)/appwrite:/backup_restore/appwrite \
alpine tail -f /dev/null
docker cp /tmp/backup/. temp_restore_container:/backup_restore
docker stop temp_restore_container
docker rm temp_restore_container
# Remove temporary files
rm -rf /tmp/backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment