I have two scripts I used before for backing up and restoring the database/volumes back when I moved my selfhosted instance from GCP to a home server. This was a few years ago though so I'm not sure if the scripts still apply today:
BACKUP:
#!/bin/bash
mkdir -p backup
docker compose exec mariadb sh -c 'exec mysqldump --all-databases --add-drop-database -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' > ./backup/dump.sql
appwrite_volumes=(uploads cache config certificates functions)
for volume in ${appwrite_volumes[@]}; do
mkdir -p backup && docker run --rm --volumes-from "$(docker compose ps -q appwrite)" -v $PWD/backup:/backup ubuntu bash -c "cd /storage/$volume && tar cvf /backup/$volume.tar ."
done
docker run --rm --volumes-from "$(docker compose ps -q appwrite-worker-deletes)" -v $PWD/backup:/backup ubuntu bash -c "cd /storage/builds && tar cvf /backup/builds.tar ."
cp docker-compose.yml backup
cp .env backup
if [ -f docker-compose.override.yml ]; then
cp docker-compose.override.yml backup
fi
RESTORE:
#!/bin/bash
docker compose exec -T mariadb sh -c 'exec mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' < ./backup/dump.sql
appwrite_volumes=(uploads cache config certificates functions)
for volume in ${appwrite_volumes[@]}; do
if [ ! -f "./backup/$volume.tar" ]; then
continue
fi
docker run --rm --volumes-from "$(docker compose ps -q appwrite)" -v $PWD/backup:/restore ubuntu bash -c "cd /storage/$volume && tar xvf /restore/$volume.tar --strip 1"
done
if [ ! -f "./backup/builds.tar" ]; then
exit 0
fi
docker run --rm --volumes-from "$(docker compose ps -q appwrite-worker-deletes)" -v $PWD/backup:/restore ubuntu bash -c "cd /storage/builds && tar xvf /restore/builds.tar --strip 1"
Is there a more official way of doing this? I was hoping through the console and it will just let me download the backup package.
read the docs, understand what's needed, understand what the script does, then apply it to whatever version you're on
Recommended threads
- edu email
my edu email is my seccondary email for github and when i signed in i dont think its registering i have an edu email using githubs education pack anyone know ho...
- All My Project is Gone
Hello everyone, please help. Why have all my projects suddenly disappeared? I received a warning via email about one of my projects being paused. When I clicked...
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...