willhlaw / node-firestore-backup-restore

Google Firebase Firestore backup and restore tool
91 stars 24 forks source link

Authentication users backup #26

Closed blaforet closed 6 years ago

blaforet commented 6 years ago

Hi First, thank you for this backup/restore solutions. Did a clone and worked fine. I have a dought, the collection Users is backup but not the actual "Authentication users". So if clone the DB and want to use it, when registering /signin, firebase will give a new User ID. Therefore, the user will not have is previous config and other data access.

Any solutions? Thank you

willhlaw commented 6 years ago

Absolutely. Here is what has worked for me.

> firebase use backup-firebase-project-id
> firebase auth:export userExport.json
> firebase use restore-firebase-project-id
> firebase auth:import --hash-algo='SCRYPT' --salt-separator='<from-hash-params==>' --rounds=8 --mem-cost=14 --hash-key='<from-hash-params==>' --project='restore-firebase-project-id' userExport.json

To figure out what should go in the <from-hash-params==> in the above command line, find your hash parameters through firebase admin now. Navigate to

Console > Project > Authentication > Three little dots on right side of all users > Password Hash Credentials

To see more about export and import the auth users, see the official command line documentation: https://firebase.google.com/docs/cli/auth-import.

To help you troubleshoot the command and what to use for your hash parameters, see https://github.com/firebase/firebase-tools/issues/253.

Please let me know if that works for you.

blaforet commented 6 years ago

Hi Will Yes, it did work perfectly, thank you.