Skip to content

A simple Node.js script to export Firestore collections to JSON files and download all files from Firebase Storage. Perfect for creating local backups and offline access. Fully automated process with no GUI required.

License

Notifications You must be signed in to change notification settings

elmuccho/firestore-export-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔥 Firebase Firestore & Storage Backup CLI

A simple Node.js script to export Firestore database to JSON and download all files from Firebase Storage. Ideal for local backups and offline use.


📌 Features:

Exports Firestore database as JSON
Saves each Firestore collection in a separate file (Hotels.json, Museums.json, etc.)
Downloads all images/files from Firebase Storage
Fully autonomous (No GUI required)


🚀 Installation

1️⃣ Clone the Repository

git clone https://github.com/elmuccho/firestore-export-local.git

2️⃣ Install Dependencies

npm install

3️⃣ Add Your Firebase Credentials

  • Go to Firebase Console → Project Settings → Service Accounts
  • Click "Generate new private key"
  • Rename the file to service_account_key.json and place it inside the project folder.

4️⃣ Specify the Firestore collections at export.js to export

Open export.js and modify the collections array to include the Firestore collections you want to export:

const collections = ["Example", "Users", "Clubs", "Pubs", "Shops", "Restaurants"];

🔄 Export Firestore Database

npm run export

This will create separate JSON files for each Firestore collection.


📥 Download All Files from Firebase Storage

npm run eximages

This will download all files from Firebase Storage into the images/ folder.

⚠️ Important Step for Storage Backup

To ensure correct access to your Storage bucket, go to Firebase Console → Storage → Files and copy the GS URL from there. Example:

gs://example-1d8de.firebasestorage.app

For correct usage in the script, remove gs:// and use:

example-1d8de.firebasestorage.app

🛠 Requirements

  • Node.js (v16+ recommended)
  • Firebase Admin SDK
  • A valid Firebase project

📜 License

MIT License - Free to use and modify.


🚀 Contribute & Star the Repo!

firestore-export-local

About

A simple Node.js script to export Firestore collections to JSON files and download all files from Firebase Storage. Perfect for creating local backups and offline access. Fully automated process with no GUI required.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published