First, you need to generate something called a private key from the database you want to clone. Follow these steps:
- Go to Project Settings.
- Navigate to Service Accounts.
- 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:
- Go to Project Settings.
- Navigate to Service Accounts.
- 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!