Skip to content

Instantly share code, notes, and snippets.

@Meldiron
Last active May 30, 2025 14:05
Show Gist options
  • Save Meldiron/47b5851663668102a676aff43c6341f7 to your computer and use it in GitHub Desktop.
Save Meldiron/47b5851663668102a676aff43c6341f7 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 appwrite_appwrite-executor:/backup/appwrite-executor \
-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 \
offen/docker-volume-backup:latest
# Contributors:
# - Matej Bačo (Meldiron): https://github.com/meldiron
# - AidsMcGhee: https://github.com/JakeAi
# 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 appwrite_appwrite-executor:/backup_restore/appwrite-executor \
-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
@luokelong
Copy link

After restore and run "docker-compose up -d" command I got the errors:

WARN[0000] volume "appwrite_appwrite-uploads" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-redis" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-functions" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-builds" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-cache" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-certificates" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-mariadb" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-influxdb" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume
WARN[0000] volume "appwrite_appwrite-config" already exists but was not created by Docker Compose. Use `external: true` to use an existing volume

Then, I added "external: true" under each volume.
Got error:

external volume "[volume name]" not found

What is wrong?

@joeyouss
Copy link

Hi there πŸ‘‹πŸ»
Please make sure that Appwrite did NOT run on this server previously. The error says it was found which implies Appwrite did run there.

@lucasctd
Copy link

lucasctd commented May 30, 2023

@joeyouss hey, it's not the case. The script will restore the volumes that's why we see that message.

@luokelong so, the service is looking for a volume named as appwrite-builds but the script creates it as appwrite_appwrite-builds that's why it fails.

I had to remove the appwrite_ prefix from the script to make it work.

In fact, if you look at your current server, you'll see the volumes were created there with that prefix so I have no idea why it works in my old server, even though it has a prefix there, but does not work after the restoration (I am using the same docker-compose.yml from the production server)

@aallnneess
Copy link

Hey,
I just wanted to give you quick feedback that it worked 100% perfectly for me.
thanks great!

@barart
Copy link

barart commented Mar 14, 2024

Make sure to stop Appwrite before this backup

^^ by this you mean stop all containers? or just appwrite container?

@lucasctd
Copy link

@barart I think it's only the appwrite containers

@liudonghua123
Copy link

Does it work for https://appwrite.io/docs/advanced/self-hosting#manual, I use docker-compose.yml and .env. And I also have updated some configurations on .env file.

@larmaysee
Copy link

larmaysee commented May 30, 2025

i'm not sure that even i restore success, there is no my data anymore in the database as well as console users. Any thought? backup sql dump as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment