Skip to content
Back

What's the recommended way to backup Appwrite?

  • 0
  • Self Hosted
  • Databases
  • General
kathelia.dokgu
27 May, 2025, 04:40

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:

TypeScript
#!/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:

TypeScript
#!/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.

TL;DR
To backup and restore Appwrite, consider using the provided script from the official documentation. If the previously used scripts are still functional, ensure they align with the current version. For a potential more official method, explore the console for a feature that allows downloading the backup package directly.
Steven
27 May, 2025, 04:53

read the docs, understand what's needed, understand what the script does, then apply it to whatever version you're on

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more