firebase-github-backup v1.0.17
🔥🗄️ Firebase GitHub Backup
Automagically backup your Firebase Cloud Firestore database to a GitHub repository, with AES-256 encryption. The GitHub Actions workflow runs every week and stores encrypted backups in the ./backups directory as .zip files.
⭐ Getting started
- Fork this repository
- Add required repository secrets
Backup files will be created weekly, and can be downloaded and manually decrypted for viewing. You can also use the npm run decrypt script to decrypt all stored files. As an example, our production database' backups are available in the ./backups directory of this repository.
⚙️ Configuration
Environment variables
Locally, environment variables are loaded from a .env file. For GitHub Actions, add the following as repository secrets (see Creating and storing encrypted secrets):
FIREBASE_SERVICE_ACCOUNT_KEYis the Firebase Service Account Key in JSON formatFIREBASE_DATABASE_URLis the Firebase Cloud Firestore database URL, e.g., https://example.firebaseio.comBACKUPS_DIRECTORYis the directory to save backups in, defaults tobackupsKEYis the key for AES-256 encryption, can be any length since it is hashedINITIALIZATION_VECTORis the IV for AES-256, can be any length since it is hashed
Deployment
Run the script using ts-node:
npm run runYou can also decrypt all backups in the directory:
npm run decryptCompile TypeScript and run Node.js script:
npm run build && npm run start