-
-
Save Meldiron/47b5851663668102a676aff43c6341f7 to your computer and use it in GitHub Desktop.
# 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 |
I've used the docker-compose.yaml and .env I have in my server and just needed to add external: true
to each volume in order to be able to attach them to my containers:
volumes:
appwrite-mariadb:
external: true
appwrite-redis:
external: true
appwrite-cache:
external: true
appwrite-uploads:
external: true
appwrite-certificates:
external: true
appwrite-functions:
external: true
appwrite-builds:
external: true
appwrite-influxdb:
external: true
appwrite-config:
external: true
appwrite-executor:
external: true
otherwise I would get the warning below:
Warning: "volume [volume name] already exists but was not created by Docker Compose. Use external: true to use an existing volume"
I also had to remove the appwrite_ prefix from your scripts since the containers are not expecting the volumes to have that prefix :D
Thanks for you hard work anyway.
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?
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.
@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)
Hey,
I just wanted to give you quick feedback that it worked 100% perfectly for me.
thanks great!
Make sure to stop Appwrite before this backup
^^ by this you mean stop all containers? or just appwrite container?
@barart I think it's only the appwrite containers
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.
Hello Buddy, hope you are doing well.
I tried to run your script but the docker-compose.yml and .env files are being created as folders XD
any idea of what could be wrong?
I am running docker on Ubuntu 22.04.2 LTS