7

What is the best way to clone or duplicate an entire firebase installation to a temporary one?

I would like to duplicate my production firebase to a temporary firebase in order to test some new code and transform the data ahead of our next product upgrade.

TTimo
  • 1,276
  • 1
  • 13
  • 20

2 Answers2

13
  1. Log in to your Firebase dashboard
  2. Go to the Forge that you want to back up
  3. Click the "Export JSON" button at the top right
  4. Go to another Forge, where you want to create a backup
  5. Click the "Import JSON" at the top right

You may also want to look at this question to automate the export/import process using the REST API.

Community
  • 1
  • 1
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
1

First, you need to generate something called a private key from the database you want to clone. Follow these steps:

  1. Go to Project Settings.
  2. Navigate to Service Accounts.
  3. Scroll down and click on 'Generate Private Key'.

Second, rename the generated file to 'appConfig.json'.

Next, open your terminal and enter the following command:

npx -p node-firestore-import-export firestore-export -a appConfig.json -b backup.json

Wait until the process is complete. Now, go to the new database where you want to import your cloned Firebase database. Follow these steps:

  1. Go to Project Settings.
  2. Navigate to Service Accounts.
  3. Scroll down and click on 'Generate Private Key'.

Second, rename the generated file to 'appConfig2.json'.

In your terminal, enter the following command:

npx -p node-firestore-import-export firestore-import -a appConfig2.json -b backup.json

You will receive a warning message asking, 'Proceed with import? (y/n)'. Type 'yes' to proceed.

And voila, you're done!

Godfather
  • 21
  • 3