-
-
Save stnguyen90/fee636ff652b8ecbf761935b2aa254fb to your computer and use it in GitHub Desktop.
#!/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 |
#!/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" |
#!/bin/bash | |
set -e # exit when any command fails | |
# create a gzipped archive of the backup | |
timestamp=`date -u +"%Y-%m-%dT%H:%M:%SZ"` | |
tar -zcf "./backup-$timestamp.tar.gz" backup | |
# delete the backup folder | |
rm -rf backup |
I got it ;)
Use manual installation on MacOS, https://appwrite.io/docs/installation#manual
- do not use automated script.
With manual installation, you create "appwrite" folder with two files; after installation, backup script will run from it without any issues.
- do not use automated script.
@FuadEfendi, FYI the install command creates an appwrite
folder with the docker-compose.yml
and .env
files.
stnguyen90, where it creates it? In LinuxKit VM run on top of MacOS? Yes I saw log messages; there is no such path: /usr/src/code
, neither on Mac, nor in Linux VM.
Manual installation is simpler than automated, and it works.
Contradictory, you have to click keys on keyboard less times with manual installation than with so-called "automated".
where it creates it?
The appwrite folder is created in the folder where the install command is executed. Notice the volume mount: --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw
click keys on keyboard less times with manual installation
The 1 command installation makes it really easy for newcomers as it prompts for some values rather than requiring users to scour the docker-compose.yml or .env file for what to update.
Thank you Steven!
@stnguyen90 it would be great if you add this scripts links in docs: https://appwrite.io/docs/production
And alos i feel dedicated section is needed in docs for backup & restore
I've updated the restore script to skip over any tar files that don't exist.
How to do it on MacOS? thanks