๋ฐ์ดํฐ์ธํธ๋ก Firestore ์๋ฎฌ๋ ์ดํฐ์ ์ธ์คํด์ค๋ฅผ ์์ฑํ ์ ์๋ ๊ฐ๋ฅ์ฑ์ด ์์ผ๋ฉด ์ข์ ๊ฒ์ ๋๋ค.
ํ์ฌ ์๋ฎฌ๋ ์ดํฐ์ ์ธ์คํด์ค๋ฅผ ์ด๊ธฐํํ๊ฑฐ๋ ์ฌ์ค์ ํ๊ธฐ ์ํด ์ผ๊ด ์ฐ๊ธฐ๋ฅผ ์ํํ๊ณ ์์ต๋๋ค. ๋ฌธ์ ๋ 120๊ฐ ์์ (ํ ์คํธ ๋ฐ์ดํฐ ์ธํธ)์ ์ ๋ฐ์ดํธํ๋ ๋ฐ ๊ฑฐ์ 3์ด๊ฐ ๊ฑธ๋ฆฐ๋ค๋ ๊ฒ์ ๋๋ค.
์ค๋ ์ท์์ Firestore ์๋ฎฌ๋ ์ดํฐ ์ธ์คํด์ค๋ฅผ ์์ฑํ๊ฑฐ๋ ๋๊ท๋ชจ ์ ๋ฐ์ดํธ์ ๋ํ ์๋ฎฌ๋ ์ดํฐ์ ์ฑ๋ฅ์ ๊ฐ์ ํ ์ ์์ต๋๊น?
์ด๊ธฐํ ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค "์ค๋ ์ท"์ ๋ก๋ํ๋ ๊ฒ์ด ์ข๋ค๋ ๋ฐ ๋์ํฉ๋๋ค. ํ์ฌ ๊ฐ๋ฐ์ ์ํด ๋ก์ปฌ์์ firestore ๋ฐ ํจ์ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์คํํ๊ณ ์์ง๋ง ํ ์คํธ ๋ฐ์ดํฐ๊ฐ ์๋ DB๋ฅผ ์๋ํ๋ฉด ๋ง์ firestore ํจ์ ํธ๋ฆฌ๊ฑฐ๊ฐ ์คํ๋ฉ๋๋ค. ์ด๊ฒ์ ๋งค์ฐ ๋ฐ๋์งํ์ง ์์ต๋๋ค. ๋ฐ๋ผ์ ์ด๊ธฐ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ธฐ๋ฅ ๋๋ ๋ ๋์ Firestore ๋ฐ์ดํฐ ์ง์์ฑ์ ๋์คํฌ์ ๋ก๋ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ธฐ๋ฅ์ ๋ํ ๊ณํ์ด ์์ต๋๊น?
ํจ์ ์์ด ๋ฐ์ดํฐ๋ฅผ ์๋ํ๊ณ ์ถ๋ค๋ ์ ์ ์ง์ ํด์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค.
๋ฐ์ฌ. ์์๋ฐฉํธ์ผ๋ก ์ฐ๋ฆฌ๋ "ํ์
off" ํจ์๋ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๋ ๋์ ํน์ ํธ์ถ๋ก ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค.
ํน์ ํ
์คํธ์๋ ์ ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๊ฒ์ ์ฌ์ฉํ์๊ฒ ์ต๋๊น?
๊ทธ๋ฌ๋ ์ฅ๊ธฐ์ ์ผ๋ก ์ฐ๋ฆฌ๋ ์์ /์์ถ์ด ํ์ํฉ๋๋ค.
2019๋ 10์ 12์ผ ํ ์์ผ ์ค์ 11์ 54๋ถ Wyatt Ades [email protected]์ด ๋ค์๊ณผ ๊ฐ์ด ์ผ์ต๋๋ค.
๋ฐ์ดํฐ๋ฒ ์ด์ค "์ค๋ ์ท"์ ๋ก๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ด๊ธฐํ. ํ์ฌ Firestore ๋ฐ ๊ธฐ๋ฅ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์คํํ๊ณ ์์ต๋๋ค.
๊ฐ๋ฐ์ ์ํด ๋ก์ปฌ์ ์์ง๋ง ํ ์คํธ ๋ฐ์ดํฐ๋ก DB๋ฅผ ์๋ํ๋ฉด
์ firestore ํจ์ ํธ๋ฆฌ๊ฑฐ๊ฐ ์คํ๋ฉ๋๋ค. ์ด๊ฒ์ ๋งค์ฐ ๋ฐ๋์งํ์ง ์์ผ๋ฏ๋ก
์ด๊ธฐ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ธฐ๋ฅ์ ๋ํ ๊ณํ์ด ์์ต๋๊น?
๋ ์ข์ ์ ์ ๋ฐ์ดํฐ ์ง์์ฑ์ ๋์คํฌ์ ์ ์ฅํ๋ ๊ฒ์ ๋๋ค.โ
์ด ์ค๋ ๋์ ๊ฐ์ ํ๊ธฐ ๋๋ฌธ์ ์ด ๋ฉ์์ง๋ฅผ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/firebase/firebase-tools/issues/1167?email_source=notifications&email_token=ACATB2VEE7BBI75HECFTE23QOIMOLA5CNFSM4G5NG5X2YY3PNVWWK3TUL52HS4DFVEXG43NVMVBW
๋๋ ๊ตฌ๋ ์ทจ์
https://github.com/notifications/unsubscribe-auth/ACTB2WHUTO43JISN54J4U3QOIMOLANCNFSM4G5NG5XQ
.
๋ค, ์ง๊ธ์ผ๋ก์๋ ์ข์ ํด๊ฒฐ์ฑ ์ด ๋ ๊ฒ์ ๋๋ค. ๊ฐ์ฌํฉ๋๋ค!
์์ง ์ด์ ๋ํ ์ด์ ํ๊ฐ ์ค์ ๋์ง ์์์ต๋๊น? ํ์ง๋ง ์ฌ๊ธฐ ์ด ํ์ ๋ํด ์ง๊ธ ๋ด๊ฐ ์ข์ํ๋ ํ ๊ฐ์ง๋ ๋ ํ๋์ ์ด๊ณ ๋ฐ์์ด ๋น ๋ฅธ ๊ฒ ๊ฐ์ต๋๋ค.
Firestore db์ ํจ๊ป ์ด ๋ฒ์์ ์ค์๊ฐ db๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๊น?
@anantanandgupta ์์ง ์ด์ ํ๊ฐ ์์ง๋ง ์งํ ์ํฉ์ ๋ํด ๊ณต๊ฐํ๋ ค๊ณ ๋ ธ๋ ฅํฉ๋๋ค! ๊ทธ๋ฆฌ๊ณ ๋ฒ์์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋ฎฌ๋ ์ดํฐ๋ ์ถ๊ฐํ์ต๋๋ค. ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ ์ฝ์ง๋ง(JSON ํ์) Cloud Functions๋ฅผ "์ผ์ ์ค์ง"ํ๋ ๋ฐ ์ฌ์ ํ ๋์์ด ํ์ํฉ๋๋ค.
๋๋ ๋ด๊ฐ ์ข์ ์์ ์๋ค๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ค์๋๋ฅผ ๋ง์๋๋ฆฌ์๋ฉด ์ ๋ ์ด ๊ฑฐ๋ํ ํ๋ซํผ์ Firebase๋ฅผ ์ค์ฌ์ผ๋ก ์์ ํ ์ค๊ณํ์ผ๋ฉฐ ๋ชจ๋๊ฐ ์ด์ ๋ฐ๋ํ์ต๋๋ค. ํ์ง๋ง ์ ๋ ธ๋ ฅ์ผ๋ก ์ ๋ ์ง๊ธ๊น์ง Firebase๋ฅผ ๊ธฐ์ ๋ก ์ฌ์ฉํ๊ธฐ๋ก ํ ๊ฒฐ์ ์ด ํ๋ฆฌ์ง ์์๋ค๋ ๊ฒ์ ์ฆ๋ช ํ์ต๋๋ค. ์ด ์์ ์์ ํด๋ผ์ฐ๋์์ ํธ์คํ ๋๋ ๊ณตํต ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ๊ฐ๋ฐ์๊ฐ ์ฌ๋ฌ ๊ธฐ๋ฅ์ ์์ ํ๋ ๊ฒ์ด ๋ถ๊ฐ๋ฅํด์ก์ต๋๋ค. ๋ฐ๋ผ์ ์ฐ๋ฆฌ ๊ฐ์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ก์ปฌ ๋ณต์ฌ๋ณธ์์ ์์ ํ ์ ์๋ค๋ฉด ํจ์ฌ ์ฝ๊ณ ํจ์จ์ ์ผ ๊ฒ์ ๋๋ค.
Firestore ์๋ฎฌ๋ ์ดํฐ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ๊ธฐ๋ฅ(์ฆ, "์๋" ๋ฐ์ดํฐ๋ก ์ด๊ธฐํ)์ ๋ค์ ๋ฆด๋ฆฌ์ค์์ ์์ด์ง ๊ฒ์ ๋๋ค. ์ฒ์์๋ ์ฝ๊ฐ ์๋์ ์ด๋ฉฐ ํ์ ๋ฆด๋ฆฌ์ค์์ ๋ ๋์ ๋๊ตฌ๋ฅผ ์ถ๊ฐํ ๊ฒ์ ๋๋ค.
์ค์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋ฎฌ๋ ์ดํฐ์ ํ์ํ ๊ฒ์ด ๋ฌด์์ธ์ง ์ดํด๋ด ๋๋ค.
@ryanpbrewster "์๋" ๋ฐ์ดํฐ๋ฅผ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ฌธ์๊ฐ ์์ต๋๊น?
@SamyPesse ์ด๊ฒ์ Emulator JAR ์์ฒด ๋ด๋ถ์์ ๊ตฌํ๋์์ง๋ง( @ryanpbrewster๊ฐ ๋งํ๋ฏ์ด) ์ค์ ๋ก ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์ํํ๊ธฐ ์ํด firebase-tools
๋ฅผ ํตํด API๋ฅผ ๋
ธ์ถํ์ง ์์์ผ๋ฏ๋ก ์์ง ์ฌ์ฉํ ์ ์๋ ๊ฒ์ด ์๋๋๋ค.
์ด๊ฒ์ด ์ด๋ป๊ฒ ์๋ํ ๊ฒ์ผ๋ก ์์ํ๋์ง ๊ณต์ ํด ์ฃผ์๊ฒ ์ต๋๊น? ๋น์ ์์ ํ๋๊ทธ ์ ํธ firebase
๋ช
๋ น์ ํ๋ firebase.json
๋๋ ๋ญ๊ฐ?
๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ ๋ฐ ๋ด๋ณด๋ด๊ธฐ๊ฐ ํ์ฌ ๊ตฌํ๋์ด ์์ง๋ง ์ด๋ฌํ ๊ธฐ๋ฅ์ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๋ ๋ฐฉ๋ฒ์ ์์ง ์ฐพ์ง ๋ชปํ์ต๋๋ค. ๋ฐ๋ผ์ ์ด๋ฌํ ์ง์นจ์ด ๋๋ต์ ์ด๋ผ๋ ๊ฒ์ ์๊ณ ์์ผ๋ฉฐ ์ด๋ฅผ ๊ฐ์ ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ด๋์ด๊ฐ ์ด๋ ค ์์ต๋๋ค.
ํ๋ก๋์ Firestore ์ธ์คํด์ค ๋๋ ๋ก์ปฌ ์๋ฎฌ๋ ์ดํฐ์์ ๋ด๋ณด๋ด๊ธฐ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
์๋ฎฌ๋ ์ดํฐ๋ฅผ ๋ถํ ํ๊ณ ์ํ๋ ๋๋ก ๋ฐ์ดํฐ๋ฅผ ์ฑ์๋๋ค. ๋ฐ์ดํฐ๋ฒ ์ด์ค๊ฐ ์ํ๋ ์ํ๊ฐ ๋๋ฉด ๋ด๋ณด๋ด๊ธฐ๋ฅผ ์์ฑํฉ๋๋ค.
curl "localhost:8080/emulator/v1/projects/ryanpbrewster-test:export" \
-d '{"database": "projects/ryanpbrewster-test/databases/(default)","export_directory":"."}' \
-H "Content-Type: application/json
firestore_export_1576524691/
์ ๊ฐ์ ๋๋ ํ ๋ฆฌ์ ๋ก์ปฌ ํ์ผ ์์คํ
์ผ๋ก ๋ด๋ณด๋ด๊ธฐ๋ฅผ ๋คํํฉ๋๋ค.
Google Cloud Storage ๋ฒํท์ด ํ์ํฉ๋๋ค. ํ
์คํธ ํ๋ก์ ํธ์ ๊ธฐ๋ณธ AppEngine ๋ฒํท ryanpbrewster-test.appspot.com
์ฌ์ฉํ๊ฒ ์ต๋๋ค. ์ด์
gcloud firestore export gs://ryanpbrewster-test.appspot.com/firestore-export
Firestore๋ ํ๋ก๋์
๋ฐ์ดํฐ์ ์ ์ฒด ์ฌ๋ณธ์ Google Cloud Storage์ ๋คํํฉ๋๋ค. ์ํ๋ ๊ฒฝ์ฐ --collection-ids
ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ํน์ ์ปฌ๋ ์
์งํฉ์ผ๋ก ๋ด๋ณด๋ด๊ธฐ๋ฅผ ์ ํํ ์ ์์ต๋๋ค.
์๋ฃ๋๋ฉด ๋ก์ปฌ ํ์ผ ์์คํ ์ ๋ณต์ฌํ ์ ์์ต๋๋ค(๋์ฉ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค๊ฐ ์๋ ๊ฒฝ์ฐ ์ ๋๋ก ์๋ํ์ง ์์ ์ ์์).
gsutil cp -r gs://ryanpbrewster-test.appspot.com/firestore-export .
ํ์ฌ๋ก์๋ ์๋ฎฌ๋ ์ดํฐ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ์ ์ผํ ๋ฐฉ๋ฒ์ ๋ช ๋ น์ค ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค.
java -jar ~/.cache/firebase/emulators/cloud-firestore-emulator-v1.10.2.jar \
--seed_from_export=firestore_export_1576524691/firestore_export_1576524691.overall_export_metadata
๋ชจ๋ ๊ฒ์ด ์๋๋ฉด ์๋ฎฌ๋ ์ดํฐ๊ฐ ์์๋๊ณ ๋ชจ๋ ๋ฐ์ดํฐ๊ฐ ๋ค์ด ์์ต๋๋ค.
์์๋๋ ๊ฒฝ๋ก๋ .overall_export_metadata
ํ์ผ์ ์์น์ด๋ฉฐ ๋ด๋ณด๋ด๊ธฐ ๋๋ ํ ๋ฆฌ์ ์ต์์ ์์ค์ ์์ด์ผ ํฉ๋๋ค.
๋ด๋ณด๋ด๊ธฐ์์ Firestore ๋ฐ์ดํฐ๋ฅผ ์๋ฎฌ๋ ์ดํธํ ์ ์์์ต๋๋ค. ์ด์ Firebase ์๋ฎฌ๋ ์ดํฐ ์ํธ๋ฅผ ์์ํ๋ ค๊ณ ํ๋ฉด. ์๋ฎฌ๋ ์ดํฐ๊ฐ ์ด๋ฏธ ํฌํธ์์ ์คํ ์ค์ด๋ฏ๋ก Firestore ์๋ฎฌ๋ ์ดํฐ๊ฐ ์๋ํ์ง ์์ต๋๋ค. FIRESTORE_EMULATOR_HOST ๋ณ์๋ฅผ ์ธ์ํ์ง ๋ชปํ๋ ์ค์ ๊น์ง ์๋ํ์ต๋๋ค. ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์์ํ๋ ๋์ ์๋ ๊ฒฝ๋ก๋ ๋ช
๋ น์ ๋ฐ๋ผ ์ ๋ฌํ ์ ์๋ค๋ฉด ํจ์ฌ ๋ ๋์์ด ๋๊ณ firebase emulators:start --firestore_seed_from_export = \path\to\seed\file
์ ๊ฐ์ ๊ฐ๋ฐ ์๊ฐ์ ๋ง์ด ์ค์ผ ์ ์์ต๋๋ค.
@prgwar ์ ์ ์์ +1. ์ด ์์ Firestore๋ฅผ ์ฌ์ฉํ์ฌ ์๋ฎฌ๋ ์ดํฐ ์ ํ๊ตฐ์ ์คํํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํฉ๋๊น? ์๋ฎฌ๋ ์ดํฐ์ ํจ์๋ "โ ํจ์: Cloud Firestore ์๋ฎฌ๋ ์ดํฐ๊ฐ ์คํ๋๊ณ ์์ง ์์ผ๋ฏ๋ก Firestore์ ๋ํ ํธ์ถ์ด ํ๋ก๋์ ์ ์ํฅ์ ๋ฏธ์น๊ธฐ" ๋๋ฌธ์ ํ๋ก๋์ ์ ์ฌ์ฉํฉ๋๋ค.
@prgwar ์ ์ firebase
๋ช
๋ น์์ ๊ฐ์ ธ์ค๊ธฐ/๋ด๋ณด๋ด๊ธฐ๋ฅผ ์ง์ ํ๊ธฐ ์ํ API๋ฅผ ๊ฒฐ์ ํ๋ ์ค์
๋๋ค. jar
์ง์ ์ฌ์ฉํ๋ ๊ฒ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ ๋ฟ์ด๋ฉฐ ์ค์ ๋ก ๊ฐ๋ฐ์๊ฐ ์ฅ๊ธฐ์ ์ผ๋ก ์ํํ ๊ฒ์ผ๋ก ๊ธฐ๋ํ๋ ๊ฒ์ ์๋๋๋ค.
@ srolfe26 ๋ฌธ์ ๊ฐ ๋ค๋ฅธ ๊ฒ์ฒ๋ผ ๋ค๋ฆฝ๋๋ค. Cloud Functions ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์คํ ์ค์ด์ง๋ง Firestore ์๋ฎฌ๋ ์ดํฐ๋ ์คํํ์ง ์์ต๋๋ค. firebase init emulators
๋ฅผ ์คํํ์ฌ Firestore ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ด๊ธฐํํ ๋ค์ firebase emulators:start
๋ค์ ์คํํด ๋ณด์ญ์์ค.
๋๋ฃ WSL(1 ๋๋ 2) ์ฌ์ฉ์์ ๊ฒฝ์ฐ ๋ธ๋ผ์ฐ์ ์์ ์๋ฎฌ๋ ์ดํฐ์ ์ฐ๊ฒฐํ๋ ๋ฐ ๋ฌธ์ ๊ฐ ์์ ์ ์์ต๋๋ค. ์์ ๋ช
๋ น์ --host 0.0.0.0
ํ๋๊ทธ๋ฅผ ์ถ๊ฐํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
java -jar ~/.cache/firebase/emulators/cloud-firestore-emulator-v1.10.2.jar \
--seed_from_export=firestore_export_1576524691/firestore_export_1576524691.overall_export_metadata \
--host 0.0.0.0
์ฌ์ฉ์ '@prgwar๊ฒ ์ต๋๊น ์ ์ --firestore_seed_from_export =
๊ทธ๋ ๋ค๋ฉด ๊ธฐ๊บผ์ด PR์ ํ ์ํฅ์ด ์์ต๋๋ค. ๊ณต์ด ๊ตด๋ฌ๊ฐ๋ ๊ฒ์ ์ด๋ป๊ฒ ๋์ธ ์ ์์ต๋๊น?
๋ํ ์ค์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋ฎฌ๋ ์ดํฐ์์ ๋์ผํ seed_from_export ๊ธฐ๋ฅ์ ๊ตฌํํ ์ ์๋ค๋ฉด ์ข๊ฒ ์ต๋๋ค.
@spencerwhyte ์ ์์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค! ์ ๋ ์ง๊ธ ์ด ๋ฌธ์ ๋ฅผ ์ ๊ทน์ ์ผ๋ก ํด๊ฒฐํ๊ณ Firestore์ RTDB, ๊ทธ๋ฆฌ๊ณ ๋ฏธ๋์ ๋ชจ๋ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ง์ํ ์์ ์ ํ๊ณ ์์ต๋๋ค.
์ด ์ผ๋ฐ์ ์ธ ํ๋ฆ์ ๋ํด ์ด๋ป๊ฒ ์๊ฐํ์ญ๋๊น?
metadata.json
ํ์ผfirebase emulators:start --import="./folder-with-backup"
firebase emulators:export
๊ทธ๊ฒ์ด ์ ๊ฐ ํ์ฌ ์์ ํ๊ณ ์๋ ๊ฒ์ ๋๋ค. ์ ๋ ๊ทธ๊ฒ์ด ๊ฐ์ฅ ์ ์ฐํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ง๋ง ํผ๋๋ฐฑ์ ๋งค์ฐ ๊ฐ๋ฐฉ์ ์ ๋๋ค.
@samtstern ๋ฐ๊ฐ ์ต๋๋ค!
์ด ๋์์ธ์ ์๋ฎฌ๋ ์ดํฐ ๋ด๋ณด๋ด๊ธฐ ํ์/๋ฐฑ์
ํ์์ด ์์
ํ ์ ์๋ ํ ์๋ฒฝํ๊ฒ ๋ค๋ฆฝ๋๋ค. ํ๋ก๋์
์ ๋ฐฑ์
๊ณผ ๋์ผํ ํ์์ด๋ฉด ๋ฉ๋๋ค. ํธ๋ฆฌ๊ฑฐ๋ฅผ ์คํํ์ง ์๊ณ ํตํฉ ํ
์คํธ๋ฅผ ์ํด ๋ง์ ์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์์ผ ํฉ๋๋ค. ํ์ฌ ์ฐ๋ฆฌ๋ ํ
์คํธ ์ค์ผ ๋ ํธ๋ฆฌ๊ฑฐ๋ฅผ ๋นํ์ฑํํ๋ ๋ช ๊ฐ์ง ๊ฒ์ฌ๋ฅผ ์ํํ์ฌ ์ด์๋จ์์ง๋ง ์ด๋ฌํ ๋ณต์ก์ฑ์ ํผํ๊ณ ์ถ์ต๋๋ค. --import
๋ํ ์ด๋ฌํ ์ง์์ ํตํด ์ฐ๋ฆฌ๋ ์ผ์ ๋จ์ํํ ์ ์์ต๋๋ค.
์ฐ๋ฆฌ๋ ํ
์คํธ์ firebase emulators:exec
๋ฅผ ์ฌ์ฉํ๋ฏ๋ก exec
์์๋ ์๋ํ๋ ํ ๋ง์กฑํ ๊ฒ์
๋๋ค.
@spencerwhyte
1) ์, ๊ฐ๋ฅํ ํ ํ๋ก๋์
๊ณผ ๋์ผํ ํ์์ ํ์คํ ๊ณ ์ํ ๊ฒ์
๋๋ค. ๋ฐ๋ผ์ Firestore์ ๊ฒฝ์ฐ ๊ฐ์ ธ์ค๊ธฐ/๋ด๋ณด๋ด๊ธฐ ํ์์ ์ง์ํ๊ณ RTDB์ ๊ฒฝ์ฐ ๊ฑฐ๋ํ json
ํ์ผ์ด ๋ฉ๋๋ค.
2) ์, ์ฐ๋ฆฌ๋ emulators:exec --import
์ง์ํ ๊ฒ์
๋๋ค
ํผ๋๋ฐฑ์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
PR #1968์ ์ด ๊ธฐ๋ฅ์ ๊ตฌํํ๋ฉฐ(ํ์ฌ Firestore์๋ง ํด๋น, Realtime Database๊ฐ ๊ณง ์ ๊ณต๋ ์์ ์) ๋ค์ CLI ๋ฆด๋ฆฌ์ค์ ํฌํจ๋ ์์ ์
๋๋ค( 7.14.0
).
์ด ๊ธฐ๋ฅ์ 7.14.0
์ถ์๋์์ต๋๋ค ... ์ฌ์ฉํด ๋ณด๊ณ ์๊ฒฌ์ ์๋ ค์ฃผ์ธ์! ์ง๊ธ์ Firestore๋ง ์์ง๋ง ์ค์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค๊ฐ ๋ค์์
๋๋ค.
์ด๊ฒ์ ์ด๋์๋ ๋ฌธ์ํ๋์ด ์์ต๋๊น? ๋ํ Google Cloud Storage ๋ฒํท(๋ด๊ฐ ๊ฐ์ง๊ณ ์์ง ์์) ์์ด ํ๋ก๋์
๋ฐ์ดํฐ๋ฅผ ๋ด๋ณด๋ด๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
ํด๋ผ์ฐ๋ ๋ฐ์ดํฐ ์ ์ฅ์์์ ๋ณต์ ๋ ๋ฐ์ดํฐ ์์ด ๋ก์ปฌ์์ ํธ๋ฆฌ๊ฑฐ๋ฅผ ํ
์คํธํ๋ ๋ฐ ์ด๋ ค์์ด ์์ต๋๋ค.
@shaimo ์ฃ์กํฉ๋๋ค. ๋ฌธ์ ์์ ์ด ์กฐ๊ธ
ํ๋ก๋์ ์์ ๋ด๋ณด๋ด๋ ค๋ฉด Cloud Storage ๋ฒํท์ด ํ์ํฉ๋๋ค. ๋ด๋ณด๋ด๊ธฐ๋ Google ์๋ฒ ์ด๋๊ฐ์์ ๋ฐ์ํ๋ "๊ด๋ฆฌ๋๋" ์์ ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋ก์ปฌ ํ์ผ ์์คํ ์ ๋ํด ๊ทธ๋ฐ ์์ ์ ์คํํ ์ ์์ต๋๋ค. ํด๋ผ์ฐ๋ ๋์์ด ํ์ํฉ๋๋ค.
Firebase ํ๋ก์ ํธ๊ฐ ์๋ ๊ฒฝ์ฐ ์ค์ ๋ก ์ฌ์ฉํ ์ ์๋ ๊ธฐ๋ณธ Cloud Storage ๋ฒํท์ด ์์ผ๋ฉฐ ์ฌ๊ธฐ์๋ ์ผ๋ถ ๋ฌด๋ฃ ํ ๋น๋์ด ํฌํจ๋ฉ๋๋ค. Firebase ์ฝ์์ ์คํ ๋ฆฌ์ง ์น์ ์ผ๋ก ์ด๋ํ์ฌ ํ์ธํ์ธ์.
@samtstern ๋ฌธ์์ ์๊ฐ์ด ์ข ๊ฑธ๋ฆด ์ ์์ผ๋ ์๋ฎฌ๋ ์ดํฐ ์ธ์คํด์ค๋ก ๊ฐ์ ธ์ค๊ธฐ/๋ด๋ณด๋ด๊ธฐ ๋ฐฉ๋ฒ์ ๋ํด ๊ฐ๋ตํ ์๋ ค์ฃผ์ค ์ ์๋์?
์ด์ ์ฌ๊ธฐ์ ์ ํ๋๊ทธ์ ๋ํ ๋ช ๊ฐ์ง ๋ฌธ์๊ฐ ์์ต๋๋ค.
https://firebase.google.com/docs/emulator-suite/install_and_configure#startup
ํ์ง๋ง ์ด์จ๋ ์๋ฅผ ๋ค์ด๋ณด๊ฒ ์ต๋๋ค. ๊ฐ์ ธ์ค๊ธฐ/๋ด๋ณด๋ด๊ธฐ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ ๊ฐ์ ํฐ๋ฏธ๋ ์ฐฝ์ด ํ์ํ๋ฏ๋ก ํฐ๋ฏธ๋ 1 ๊ณผ ํฐ๋ฏธ๋ 2 ๋ผ๊ณ ๋ถ๋ฅด๊ฒ ์ต๋๋ค.
๋จผ์ ์๋ฎฌ๋ ์ดํฐ ์์
ํฐ๋ฏธ๋ 1
$ firebase emulators:start
# ...
์ ์ฅํ๋ ค๋ ๋ฐ์ดํฐ๋ฅผ ๋ช ๊ฐ ๊ตฌ์ถํ ํ ๋ค๋ฅธ ํฐ๋ฏธ๋์์ ๋ด๋ณด๋ด๊ธฐ ๋ช ๋ น์ ์คํํฉ๋๋ค.
ํฐ๋ฏธ๋ 2
$ firebase emulators:export ./mydirectory
# ...
์ด์ ./mydirectory
๋ด๋ณด๋ด๊ธฐ๊ฐ ์์ต๋๋ค. ๋ค์์ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์์ํ ๋ ๊ฑฐ๊ธฐ์์ ๊ฐ์ ธ์ค๋๋ก ์ง์ํ์ญ์์ค.
ํฐ๋ฏธ๋ 1
$ firebase emulators:start --import=./mydirectory
# ...
๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ ๋ค์ผ!
@samtstern firebase emulators:start --import ๋ช
๋ น์ ์ฌ์ฉํ์ฌ ํ๋ก๋์
๋ด๋ณด๋ด๊ธฐ์์ ๊ฐ์ ธ์ฌ ์ ์๋์?
emulators:start --import๊ฐ firebase-export-metadata.json์ ์ฐพ๊ณ ์์ง๋ง firestore-export/firestore-export.overall_export_metadata๊ฐ ์์ต๋๋ค.
@landonj ํ ์ ์์ง๋ง ํ์ฌ๋ก์๋ ์ฝ๊ฐ ๊น๋ค๋กญ์ต๋๋ค. ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ emulators:export
ํ ๋ฒ ์คํํ ๋ค์ ๋ก์ปฌ ํ์ผ์ด ์๋ ํ๋ก๋์
๋ด๋ณด๋ด๊ธฐ๋ฅผ ๊ฐ๋ฆฌํค๋๋ก JSON ํ์ผ์ ์์ ํ๋ ๊ฒ์
๋๋ค.
์์ง ์๋ฎฌ๋ ์ดํฐ์ฉ RTDB ์๋ฉ์ ๋ํ ๋ด์ฉ์ด ์์ต๋๊น?
@FergyKay ์์ง ์๋ฌด๊ฒ๋ ์์ง๋ง ์ฌ๊ธฐ๋ฅผ ๋ฐ๋ผ๊ฐ ์ ์์ต๋๋ค.
https://github.com/firebase/firebase-tools/issues/2079
์ด๊ฒ์ ๋ง์ด ํ์ํ๋ค
@landonj ์ ๋๊ฐ์ ์ผ์
@samtstern์ด ๋งํ ๊ฒ์ ์๋ํ์ง๋ง ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค...
๋ด๊ฐ ๋ญ ์๋ชปํ๊ณ ์์ด?
bdw.. ํ์ผ์ด ์กด์ฌํฉ๋๋ค!
firebase emulators:start --debug --only firestore,functions --import=/Users/ridermansb/Projects/meve.ai/backups/emulator-data
[2020-05-31T13:31:23.601Z] com.google.cloud.datastore.core.exception.DatastoreException: ์ ์ฒด ๋ด๋ณด๋ด๊ธฐ ๋ฉํ๋ฐ์ดํฐ ํ์ผ์ ๊ตฌ๋ฌธ ๋ถ์ํ์ง ๋ชปํ์ต๋๋ค.
com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseOverallMetadataFile(ExportImportUtil.java:225)
com.google.cloud.datastore.emulator.impl.ExportImportUtil.fetchEntities(ExportImportUtil.java:54)
com.google.cloud.datastore.emulator.firestore.CloudFirestore.main(CloudFirestore.java:89)
{"metadata":{"emulator":{"name":"firestore"},"message":"com.google.cloud.datastore.core.exception.DatastoreException: ์ ์ฒด ๋ด๋ณด๋ด๊ธฐ ๋ฉํ๋ฐ์ดํฐ ํ์ผ์ ๊ตฌ๋ฌธ ๋ถ์ํ์ง ๋ชปํ์ต๋๋ค.\n\tat com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseOverallMetadataFile(ExportImportUtil.java:225)\n\tat com.google.cloud.datastore.emulator.impl.ExportImportUtil.fetchEntities(ExportImportUtil.java:54)\n \tat com.google.cloud.datastore.emulator.firestore.CloudFirestore.main(CloudFirestore.java:89)\n"}}
[2020-05-31T13:31:23.602Z] ์์ธ: java.io.FileNotFoundException: /Users/ridermansb/Projects/meve.ai/backups/emulator-data/Users/ridermansb/Projects/meve.ai/backups/ 2020-05-31/2020-05-31/2020-05-31T13:19:28_6168.overall_export_metadata (ํด๋น ํ์ผ์ด๋ ๋๋ ํ ๋ฆฌ๊ฐ ์์)
{"metadata":{"emulator":{"name":"firestore"},"message":"๋ฐ์ ์์ธ: java.io.FileNotFoundException: /Users/ridermansb/Projects/meve.ai/backups/emulator-data /Users/ridermansb/Projects/meve.ai/backups/2020-05-31/2020-05-31/2020-05-31T13:19:28_6168.overall_export_metadata (ํด๋น ํ์ผ ๋๋ ๋๋ ํฐ๋ฆฌ ์์)\n"}}
[2020-05-31T13:31:23.603Z] java.base/java.io.FileInputStream.open0(๋ค์ดํฐ๋ธ ๋ฉ์๋)
java.base/java.io.FileInputStream.open(FileInputStream.java:213)
java.base/java.io.FileInputStream์ ์์ต๋๋ค.(ํ์ผ์ ๋ ฅ์คํธ๋ฆผ.java:155)
com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseOverallMetadataFile(ExportImportUtil.java:215)
... 2 ๊ฐ ๋
{"metadata":{"emulator":{"name":"firestore"},"message":"\tat java.base/java.io.FileInputStream.open0(๋ค์ดํฐ๋ธ ๋ฉ์๋)\n\tat java.base/ java.io.FileInputStream.open(FileInputStream.java:213)\n\tat java.base/java.io.FileInputStream.(FileInputStream.java:155)\n\tat com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseOverallMetadataFile(ExportImportUtil.java:215)\n\t... 2๊ฐ ๋\n"}}
์ค๋ฅ: firestore: Firestore ์๋ฎฌ๋ ์ดํฐ๊ฐ ์ฝ๋์ ํจ๊ป ์ข ๋ฃ๋์์ต๋๋ค: 1
@landonj ํ ์ ์์ง๋ง ํ์ฌ๋ก์๋ ์ฝ๊ฐ ๊น๋ค๋กญ์ต๋๋ค. ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์
emulators:export
ํ ๋ฒ ์คํํ ๋ค์ ๋ก์ปฌ ํ์ผ์ด ์๋ ํ๋ก๋์ ๋ด๋ณด๋ด๊ธฐ๋ฅผ ๊ฐ๋ฆฌํค๋๋ก JSON ํ์ผ์ ์์ ํ๋ ๊ฒ์ ๋๋ค.
์ด๊ฒ์ ํ์ฅํ ์ ์์ต๋๊น? gcloud ๋ฒํท์ ์ง์ ๊ฐ๋ฆฌํฌ ์ ์๋์? ์๋๋ฉด ๋จผ์ ๋ด๋ณด๋ด๊ธฐ ๋ด์ฉ์ ๋ก์ปฌ๋ก ๋ค์ด๋ก๋ํด์ผ ํฉ๋๊น? ์ด๋ค ํ์ผ์ ์์ ํด์ผ ํฉ๋๊น?
๋ค์์ ๋ด๊ฐ ์๋ํ ๊ฒ์ ๋๋ค.
> firebase emulators:start
> firebase emulators:export ~/emulator-data/
> # close the emulator
> gcloud firestore export gs://xxxxx-xxxxx-xxxxx/emulator/
> gsutil cp -r gs://xxxxx-xxxxx-xxxxx/emulator ~/emulator-data/
> firebase emulators:start --only firestore --import /home/gugahoi/emulator-data/emulator/ --debug
[2020-06-01T10:04:36.492Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-06-01T10:04:36.493Z] > authorizing via signed-in user
i emulators: Starting emulators: firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore"}}
[2020-06-01T10:04:36.510Z] [hub] writing locator at /tmp/hub-flux-development.json
i emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}
[2020-06-01T10:04:36.825Z] Error: ENOENT: no such file or directory, open '/home/gugahoi/emulator-data/emulator/firebase-export-metadata.json'
at Object.openSync (fs.js:458:3)
at Object.readFileSync (fs.js:360:35)
at Object.<anonymous> (/home/gugahoi/.nvm/versions/node/v12.16.3/lib/node_modules/firebase-tools/lib/emulator/controller.js:183:44)
at Generator.next (<anonymous>)
at fulfilled (/home/gugahoi/.nvm/versions/node/v12.16.3/lib/node_modules/firebase-tools/lib/emulator/controller.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Error: An unexpected error has occurred.
์์ ๋ด์ฉ์ด ์๋๋ ๊ฒ ๊ฐ์์ firebase-exports-metadata.json
ํ์ผ์ ๋ค์ ๋ด์ฉ์ผ๋ก ์
๋ฐ์ดํธ ํ์ต๋๋ค.
> cat firebase-export-metadata.json
{"version":"8.4.1","firestore":{"version":"1.11.4","path":"emulator","metadata_file":"emulator/emulator.overall_export_metadata"}}
๋ค์์ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ์ ๋๋ค.
gugahoi:~/emulator-data > tree .
.
โโโ emulator
โย ย โโโ all_namespaces
โย ย โย ย โโโ all_kinds
โย ย โย ย โโโ all_namespaces_all_kinds.export_metadata
โย ย โย ย โโโ output-0
โย ย โย ย โโโ output-1
โย ย โโโ emulator.overall_export_metadata
โโโ firebase-export-metadata.json
โโโ firebase-export-metadata.json.bak
โโโ firestore_export
โโโ firestore_export.overall_export_metadata
๊ทธ๋ฌ๋ ์ฌ์ ํ ์๋ฎฌ๋ ์ดํฐ UI์ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค.
์๋ฎฌ๋ ์ดํฐ์ ์ต์ข ์ถ๋ ฅ์ ์ถ๊ฐํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ๋๋ฐ ์ค๋ฅ ์์ด ์คํ๋์ง๋ง ๋ด ๋ฐ์ดํฐ๋ ์์ต๋๋ค.
> firebase emulators:start --only firestore --import /home/gugahoi/emulator-data/ --debug
[2020-06-01T11:31:34.256Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-06-01T11:31:34.257Z] > authorizing via signed-in user
i emulators: Starting emulators: firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore"}}
[2020-06-01T11:31:34.274Z] [hub] writing locator at /tmp/hub-flux-development.json
i firestore: Importing data from /home/gugahoi/emulator-data/emulator/emulator.overall_export_metadata {"metadata":{"emulator":{"name":"firestore"},"message":"Importing data from /home/gugahoi/emulator-data/emulator/emulator.overall_export_metadata"}}
[2020-06-01T11:31:34.302Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2020-06-01T11:31:34.303Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2020-06-01T11:31:34.303Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/home/gugahoi/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--seed_from_export","/home/gugahoi/emulator-data/emulator/emulator.overall_export_metadata","--rules","/home/gugahoi/projects/flux/flux/firestore.rules"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/home/gugahoi/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--seed_from_export\",\"/home/gugahoi/emulator-data/emulator/emulator.overall_export_metadata\",\"--rules\",\"/home/gugahoi/projects/flux/flux/firestore.rules\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2020-06-01T11:31:35.197Z] API endpoint: http://localhost:8080
{"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:8080\n"}}
[2020-06-01T11:31:35.198Z] If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
export FIRESTORE_EMULATOR_HOST=localhost:8080
Dev App Server is now running.
{"metadata":{"emulator":{"name":"firestore"},"message":"If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n export FIRESTORE_EMULATOR_HOST=localhost:8080\n\nDev App Server is now running.\n\n"}}
[2020-06-01T11:31:35.322Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2020-06-01T11:31:35.322Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2020-06-01T11:31:35.323Z] Starting Emulator UI with command {"binary":"node","args":["/home/gugahoi/.cache/firebase/emulators/ui-v1.0.0/server.bundle.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/home/gugahoi/.cache/firebase/emulators/ui-v1.0.0/server.bundle.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2020-06-01T11:31:35.395Z] Web / API server started at http://localhost:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at http://localhost:4000\n"}}
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ All emulators ready! View status and logs at http://localhost:4000 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Emulator โ Host:Port โ View in Emulator UI โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Firestore โ localhost:8080 โ http://localhost:4000/firestore โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Other reserved ports: 4400, 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
@gugahoi ๊ทํ์ ๊ฒ์๋ฌผ์ด ํด๊ฒฐ์ฑ ์ https://gist.github.com/bkuri/36cef71bcf30a5416b1c353cb81f38ed
ํด๋ผ์ฐ๋ ์คํ ๋ฆฌ์ง ์๋ฎฌ๋ ์ดํฐ ์ธ์คํด์ค๋ฅผ ์๋ํ๋ ์์ bash ์คํฌ๋ฆฝํธ์
๋๋ค. ํ๋ก์ ํธ ์ด๋ฆ๊ณผ ๋ด๋ณด๋ธ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ๋์ ๊ฒฝ๋ก๋ง ์์ผ๋ฉด ๋ฉ๋๋ค. ์: ./seed-storage.sh my-project /tmp/export
.
BTW, ์์ ์คํฌ๋ฆฝํธ๋ ์ผ๋ฐ์ ์ธ ์ฉ์์( firebase
, gcloud
๋ฐ gsutil
) ์ธ์๋ ๋งค์ฐ ์ผ๋ฐ์ ์ธ ๋ ๊ฐ์ง ๋๊ตฌ( lsof
๋ฐ screen
)์ ์์กดํฉ๋๋ค. gsutil
), ์ค์น๋์ด ์๋์ง ํ์ธํ์ญ์์ค.
์ด๊ฒ์ด ๋๊ตฐ๊ฐ๋ฅผ ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. :+1:
์ด์จ๋ ๊ธฐ์กด ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๊ฐ์ ธ์ฌ ๋ firestore ๊ธฐ๋ฅ์ด ํธ๋ฆฌ๊ฑฐ๋๋ ๊ฒ์ ํผํ๋ ค๋ฉด?
@bkuri ํด๋น ์คํฌ๋ฆฝํธ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์ฌ์ ํ Firestore ์๋ฎฌ๋ ์ดํฐ ์ฝ์์ ํ์ํ ๋ฐ์ดํฐ๋ฅผ ์ป์ ์ ์๊ธฐ ๋๋ฌธ์ ์ค์ /์ค์น์ ์ด์ํ ์ผ์ด ์ผ์ด๋๊ณ ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
@gugahoi ๋๋ถ์ ํ๋ก๋์
์์ ๋ก์ปฌ ์๋ฎฌ๋ ์ดํฐ๋ก ์ปฌ๋ ์
์ ๊ฐ์ ธ์ฌ ์ ์์์ต๋๋ค.
์ด๋ฅผ ์ํด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ์ต๋๋ค.
firebase emulators:start
emulators:export ./mydirectory
gcloud firestore export gs://my-project-bucket-id.appspot.com --collection-ids=myCollection
๋ด๋ณด๋ด๊ธฐ๋ ์ด์ _Firebase Storage_ ์๋์ ํ์์คํฌํ๊ฐ ์ด๋ฆ์ผ๋ก ์ง์ ๋ ํด๋์ ์์ต๋๋ค(์ ๋์ฌ๋ฅผ ์ฌ์ฉํ์ง ์์์ต๋๋ค. ๋ด ํ
์คํธ๋ฅผ ์ํด)gsutil cp -r gs://my-project-bucket-id.appspot.com/myCollection ./production_data_export
์ฐธ๊ณ : Windows ํ๊ฒฝ์์ ์ด ์์
์ ์ํํ์ต๋๋ค... _gsutil_์์ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. _"OSError: ํ์ผ ์ด๋ฆ, ๋๋ ํฐ๋ฆฌ ์ด๋ฆ ๋๋ ๋ณผ๋ฅจ ๋ ์ด๋ธ ๊ตฌ๋ฌธ์ด ์๋ชป๋์์ต๋๋ค."_ ํด๋์ Windows์ ํด๋ ์ด๋ฆ์ ๋ํด ์๋ชป๋ ๋ฌธ์(์: ์ฝ๋ก )๊ฐ ์๋ ๊ฒฝ์ฐ ๋๋ ์ด ์ค๋ฅ: _"OSError: Invalid argument.9.0 B]"_ ํด๋์ ๋ด๋ถ ํ์ผ์๋ ์๋ชป๋ ๋ฌธ์๊ฐ ์๋ ๊ฒฝ์ฐ. ๋ด๋ณด๋ด๊ธฐ๋ฅผ ๋ก์ปฌ๋ก ๋ค์ด๋ก๋ํ๋ ค๋ฉด gsutil mv gs://my-project-bucket-id.appspot.com/2020-05-22T02:01:06_86152 gs://my-project-bucket-id.appspot.com/myCollection
์ ๊ฐ์ด ์ ํจํ Windows ์ด๋ฆ(์: ์ฝ๋ก ์ ๊ฑฐ)์ผ๋ก ์ด๋ฆ์ ๋ฐ๊ฟ๋๋ค.firestore_export
๋ฐ๊พธ๊ณ ๋ก์ปฌ ๋ด๋ณด๋ด๊ธฐ ํด๋์์ firebase-export-metadata.json
ํ์ผ์ ๋ณต์ฌํฉ๋๋ค. ์๊ฐ์ ์ผ๋ก ๋ณด๊ธฐ ์ํด ๋ด๊ฐ ์ป์ ๊ตฌ์กฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.$ tree .
.
โโโ local_data_export
โ โโโ firebase-export-metadata.json
โ โโโ firestore_export
โ โโโ all_namespaces
โ โ โโโ all_kinds
โ โ โโโ all_namespaces_all_kinds.export_metadata
โ โ โโโ output-0
โ โโโ firestore_export.overall_export_metadata
โโโ production_data_export
โโโ firebase-export-metadata.json
โโโ firestore_export
โโโ all_namespaces
โ โโโ kind_myCollection
โ โโโ all_namespaces_kind_myCollection.export_metadata
โ โโโ output-0
โ โโโ output-1
โโโ firestore_export.overall_export_metadata
8 directories, 9 files
firebase emulators:start --import=./mock_up_data/production_data_export/
์ด ์ง์นจ์ด ๋์์ด ๋ ๋งํผ ๋ช ํํ์ผ๋ฉด ํฉ๋๋ค. Firebase ์ง์์ ๋ณด๋ค ๊ฐ๋ ฅํ ์๋ฃจ์ ์ ๊ธฐ๋ค๋ฆฌ๋ ๋์ ์ด๊ฒ์ด ๋๊ตฐ๊ฐ์๊ฒ ๋์์ด ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
๊ฐ๋จํ ์ ๋ฐ์ดํธ: ์์ ์ค๋ช ์์ ์ง์นจ์ ๊ฒ์ํ์ ๋ WSL2์์ ์ํํ๊ณ ์์๋๋ฐ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์์ง๋ง Ubuntu์์๋ ๋์ผํ ๋จ๊ณ๊ฐ ๋ฌธ์ ๊ฐ ์๋ ๊ฒ ๊ฐ์ต๋๋ค. WSL2์ ๊ฐ์ญํ๋ ๊ฒ์ด ์์ ์ ์์ต๋๋ค. .
๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ด ์์ ์ ์ํํ๊ณ ์ถ์ต๋๋ค. ๋ด ์๋ฎฌ๋ ์ดํฐ ๋ฐ์ดํฐ๋ฅผ ํ๋ก๋์ ์ผ๋ก ๊ฐ์ ธ์ค๊ณ ์ถ์ต๋๋ค. ๋ด Firestore์ 7000๊ฐ์ Google ์ํธ ํ์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ํ๋ก๋์ ์์ ์ํํ๋ ค๊ณ ํ ๋ ๊ธฐ๋ฅ์ ํธ์งํ์ฌ ๊ทธ๋ ๊ฒ ํ ์ ์์์ต๋๋ค. ๋ฉ๋ชจ๋ฆฌ ์ ํ์ด ์ด๊ณผ๋๋ฉด ํจ์ ๋ด๋ถ์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ค๋ณต ๋ฐ์ดํฐ๊ฐ ์์ฑ๋ ์ ์์ต๋๋ค. ๋ด๋ณด๋ด๊ธฐ ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ํ์ธํ๊ณ ๋ก์ปฌ ์๋ฎฌ๋ ์ดํฐ Firestore ๋ฐ์ดํฐ๋ฅผ ๋ด๋ณด๋ผ ์ ์์์ ์์์ต๋๋ค. ํ์ง๋ง ๋ก์ปฌ ๋ฐฑ์ ์ ํ๋ก๋์ ์ผ๋ก ๊ฐ์ ธ์ค๋ ๊ฒ์ ์ด๋ป์ต๋๊น?
@nvanhoesel ๊ฐ์ ธ์ค๊ธฐ/๋ด๋ณด๋ด๊ธฐ ํ์์ ํ๋ก๋์ ๋ฐ ์๋ฎฌ๋ ์ดํฐ์์ ๋์ผํฉ๋๋ค. ๊ทธ๋ฌ๋ ๊ทํ์ ๊ฒฝ์ฐ๋ ๋๋ฌธ ์ฌ์ฉ ์ฌ๋ก์ด๋ฏ๋ก Firestore์์ ์ฌ๋ฐ๋ฅด๊ฒ ๊ฐ์ ธ์ฌ ์ ์๋๋ก Google Cloud Storage๋ก ์๋ฎฌ๋ ์ดํฐ ๋ด๋ณด๋ด๊ธฐ๋ฅผ ๊ฐ์ ธ์ค๋ ค๋ฉด ์ง์ ์์ ์ ์ํํด์ผ ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Firestore ์๋ฎฌ๋ ์ดํฐ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ๊ธฐ๋ฅ(์ฆ, "์๋" ๋ฐ์ดํฐ๋ก ์ด๊ธฐํ)์ ๋ค์ ๋ฆด๋ฆฌ์ค์์ ์์ด์ง ๊ฒ์ ๋๋ค. ์ฒ์์๋ ์ฝ๊ฐ ์๋์ ์ด๋ฉฐ ํ์ ๋ฆด๋ฆฌ์ค์์ ๋ ๋์ ๋๊ตฌ๋ฅผ ์ถ๊ฐํ ๊ฒ์ ๋๋ค.
์ค์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋ฎฌ๋ ์ดํฐ์ ํ์ํ ๊ฒ์ด ๋ฌด์์ธ์ง ์ดํด๋ด ๋๋ค.