LoginSignup
0

posted at

updated at

Firebase Realtime DatabaseとAuthenticationのデータをEmulator上に全部コピーする

Databaseに認証ルールとかがある場合にはAuthenticationもEmulator上に存在しないとうまく動かない

# 保存先のディレクトリ構造を生成させる
$ npx firebase emulators:exec "exit 0" --export-on-exit /tmp/firebase-test-export --project your-own-app

# Databaseの内容をEmulatorでimportするディレクトリに書き出し
$ npx firebase database:get / --export --output /tmp/firebase-test-export/database_export/your-own-app.json  --project your-own-app

# Authenticationの内容をEmulatorでimportするディレクトリに書き出し
$ npx firebase auth:export /tmp/firebase-test-export/auth_export/accounts.json --project your-own-app

# 上記で書き出されたディレクトリをimportしてEmulatorを起動
$ npx firebase emulators:start --import /tmp/firebase-test-export/database_export --project your-own-app

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0