Minimalistic Appwrite schema dumper with data backup, restore features
This backup tool will generate query for each document in AppWrite database and save them as a json files on a hard drive. That means It can handle as much documents as you need. Also there is a script to run AppWrite in Docker on localhost so you can test your backup. Build on top of AsyncGenerator API
Got a question? Feel free to ask It in issues, I need traffic
- Install Appwrite CLI and login
Windows
npm install -g appwrite-cli
Set-ExecutionPolicy RemoteSigned # In PowerShell as Administrator
appwrite client --endpoint https://cloud.appwrite.io/v1
appwrite login
Linux
sudo npm config set unsafe-perm true
sudo npm install -g appwrite-cli
appwrite client --endpoint https://cloud.appwrite.io/v1
appwrite login
- [BACKUP, RESTORE] Write
.env
config in the root (/appwrite-backup-tool-main/.env
) by using .env.example
APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_PROJECT_ID=64b53d0c41fcf5093b12
APPWRITE_API_KEY=****
APPWRITE_SELF_SIGNED=1
- [RESTORE] Copy
appwrite.json
to the root (collections schema). See https://appwrite.io/docs/tooling/command-line/deployment
Crossplatform
npx -y rimraf backup
npm run appwrite:backup
- Deploy all local data to AppWrite server (clear installation is optional but recommended)
Crossplatform
npm run appwrite:restore
- Dump currend DB schema
Windows
npm run appwrite:fetch:windows
Linux
npm run appwrite:fetch
- Push new DB schema to AppWrite instance
Windows
npm run appwrite:push:windows
Linux
npm run appwrite:push
- Show changed collection attributes by comparing
appwrite.json
andappwrite.prev.json
Crossplatform
npm run appwrite:diff
- Output
...
COLLECTION APARTMENT
ADD rent_kom_menedzher_unit
ADD rent_kom_agency_unit
ADD rent_kom_kommisiya_agenstva
CHANGED rent_kom_czena_sobstvennika_valyuta (array true -> false)
CHANGED rent_kom_komissiya_agenstva_unit (array true -> false)
...
- Run AppWrite with Docker Compose
Windows
npx -y open-cli http://localhost:8080/
npm run appwrite:start:windows
Linux
npx -y open-cli http://localhost:8080/
npm run appwrite:start
- Authorize CLI in Docker AppWrite instance
Crossplatform
appwrite client --selfSigned true --endpoint http://localhost:8080/v1
appwrite login
- Start AppWrite self-hosted instance (after
.env
changed)
docker-compose up -d --remove-orphans --renew-anon-volumes
- Stop AppWrite self-hosted instance
docker-compose down
- Uninstall AppWrite by removing all volumes and containers (clean install). Also remove networks to avoid mariadb DNS lookup error when downgrade from higher version of AppWrite to lower
docker stop $(docker ps --filter status=running -q)
docker rm $(docker ps -aq)
docker volume rm $(docker volume ls -q --filter dangling=true)
docker rmi $(docker images -a -q)
docker network prune --force --filter until=1s
Looks like AppWrite file endpoint is limited to 60 requests in every 1 minutes per IP address
. So I added a delay, you can change it If you need to
Quite usefull when
AppwriteException [Error]: The document data is missing. Try again with document data populated
...
const DOCUMENT_WRITE_DELAY = 1500;
const FILE_UPLOAD_DELAY = 2_000;