Package Exports
- appw-cli
- appw-cli/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (appw-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Appw CLI
CLI tool to automate Appwrite backup and restore operations using Docker commands.
Features
- π Full Backup & Restore: Complete backup of MariaDB database and all Docker volumes
- π¦ Partial Restore: Restore only specific components (database, functions, uploads, or builds)
- β Integrity Verification: Verify backup files before attempting restore
- βΈοΈ Automatic Container Management: Optional stop/restart of Appwrite containers
- π·οΈ Custom Prefixes: Support for custom container name prefixes
- π Timestamped Backups: Automatic timestamping to prevent overwrites
- π OpenSSL Key Management: Automatic backup and validation of encryption keys
Prerequisites
- Docker: Must be installed and running
- Node.js: Version 16.0.0 or higher
- Appwrite: Self-hosted instance with Docker containers
Installation
From npm (when published)
npm install -g appw-cliFrom source
git clone <repository-url>
cd appw-cli
npm install
npm run build
npm linkUsage
Backup Command
Create a complete backup of your Appwrite instance:
appw backupBy default, the backup command will:
- Stop all Appwrite containers before backing up volumes
- Create backups of the database and all volumes
- Restart all containers after completion
Options
-p, --prefix <prefix>: Container name prefix (default:appwrite)-o, --output <directory>: Output directory for backups (default:./backups)-d, --database-only: Backup only the database (skips volumes and container restart)
Examples
# Full backup (stops containers, backs up everything, restarts containers)
appw backup
# Backup with custom prefix
appw backup --prefix myappwrite
# Database-only backup (containers keep running, no volumes backed up)
appw backup --database-only
# Backup to specific directory
appw backup --output /var/backups/appwriteWhat gets backed up
- MariaDB Database (
dump.sql) - All databases, collections, documents, users, and configurations - Functions Volume (
functions.tar) - All cloud function data - Uploads Volume (
uploads.tar) - All uploaded files - Builds Volume (
builds.tar) - All build artifacts - Configuration (
config.json) - Backup metadata and_APP_OPENSSL_KEY_V1
Restore Command
Restore your Appwrite instance from a backup:
appw restore ./backups/backup-2025-11-25-143022By default, the restore command will:
- Stop all Appwrite containers before restoring volumes
- Restore the database and all volumes
- Restart all containers after completion
Options
-p, --prefix <prefix>: Container name prefix (default:appwrite)--only-database: Restore only the database (containers keep running)--only-functions: Restore only the functions volume--only-uploads: Restore only the uploads volume--only-builds: Restore only the builds volume
Examples
# Full restore (stops containers, restores everything, restarts containers)
appw restore ./backups/backup-2025-11-25-143022
# Restore only the database (containers keep running)
appw restore ./backups/backup-2025-11-25-143022 --only-database
# Restore only uploads and functions
appw restore ./backups/backup-2025-11-25-143022 --only-uploads --only-functions
# Restore to different Appwrite instance
appw restore ./backups/backup-2025-11-25-143022 --prefix myappwriteVerify Command
Verify the integrity of a backup before restoring:
appw verify ./backups/backup-2025-11-25-143022What gets verified
- β Backup directory structure
- β Presence of all required files
- β Configuration file validity
- β File sizes (warns if empty or suspiciously small)
- β TAR archive integrity
- β SQL dump format validation
- β OpenSSL key presence
Examples
# Verify a backup
appw verify ./backups/backup-2025-11-25-143022
# Verify before restore
appw verify ./backups/backup-2025-11-25-143022 && \
appw restore ./backups/backup-2025-11-25-143022Backup Structure
Each backup creates a timestamped directory:
backups/
βββ backup-2025-11-25-143022/
βββ dump.sql # MariaDB database dump
βββ functions.tar # Functions volume backup
βββ uploads.tar # Uploads volume backup
βββ builds.tar # Builds volume backup
βββ config.json # Backup configurationconfig.json Example
{
"timestamp": "2025-11-25-143022",
"opensslKey": "your-openssl-key-here",
"prefix": "appwrite",
"version": "1.6.0"
}Note: The version field stores the Appwrite version extracted from the Docker image (e.g., appwrite/appwrite:1.6.0). If the version cannot be determined, it will be set to "unknown".
Container Naming
The CLI expects Appwrite containers to follow this naming pattern:
- Main container:
{prefix}(e.g.,appwrite) - MariaDB container:
{prefix}-mariadb(e.g.,appwrite-mariadb) - Other containers:
{prefix}-*(e.g.,appwrite-redis, `appwrite-worker-*)
If your containers use a different prefix, specify it with --prefix:
appw backup --prefix myappBest Practices
1. Full Backups for Production
For production environments, always use full backups (default behavior):
appw backupThis ensures data consistency by stopping containers during volume backups.
2. Verify Backups
Always verify backups after creation:
appw backup
appw verify ./backups/backup-2025-11-25-1430223. Test Restores
Periodically test your restore process in a non-production environment.
4. Store Backups Safely
- Keep backups in multiple locations
- Store backups on different servers/cloud storage
- Consider encrypting backup files
5. Automated Backups
Use cron for scheduled backups:
# Daily full backup at 2 AM
0 2 * * * /usr/local/bin/appw backup --output /var/backups/appwrite
# Hourly database-only backup (faster, no downtime)
0 * * * * /usr/local/bin/appw backup --database-only --output /var/backups/appwrite-hourly6. Backup Retention
Implement a retention policy to manage disk space:
# Keep only last 7 days of backups
find /var/backups/appwrite -type d -name "backup-*" -mtime +7 -exec rm -rf {} \;Troubleshooting
Permission Denied
If you get permission errors when running Docker commands:
# Add your user to the docker group
sudo usermod -aG docker $USER
# Or run with sudo
sudo appw backupContainer Not Found
If the CLI cannot find your containers:
# List all containers to find your prefix
docker ps -a
# Use the correct prefix
appw backup --prefix your-actual-prefixOpenSSL Key Warning
If you see a warning about missing _APP_OPENSSL_KEY_V1:
- Check your Appwrite
.envfile for the key - Manually add it to
config.jsonif needed - Ensure it's set correctly before restoring
Large Backup Files
For large Appwrite instances:
- Ensure sufficient disk space
- Consider backing up to external storage
- Use
--only-*flags for partial restores if needed
Migration Between Servers
To migrate Appwrite from one server to another:
On source server:
appw backup
Transfer backup:
scp -r ./backups/backup-2025-11-25-143022 user@destination:/path/
On destination server:
# Ensure Appwrite is installed and containers exist appw restore ./backup-2025-11-25-143022Verify
_APP_OPENSSL_KEY_V1:- The key is automatically backed up in
config.json - Ensure it matches in your destination server's
.envfile
- The key is automatically backed up in
Environment Variables
The CLI reads the following from Docker containers:
MYSQL_USER- MariaDB username (defaults toroot)MYSQL_PASSWORD- MariaDB password_APP_OPENSSL_KEY_V1- Appwrite encryption key (backed up in config.json)
Development
Build from source
npm install
npm run buildRun in development mode
npm run devLink locally
npm linkLicense
MIT
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Support
For issues and questions:
- Check the troubleshooting section
- Review Appwrite's official backup documentation
- Open an issue on GitHub
Disclaimer
This tool is not officially affiliated with Appwrite. Always test backups and restores in a non-production environment first. The authors are not responsible for any data loss.