-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import admin from 'firebase-admin'; | ||
import { AppEnv, AppError } from '../../shared'; | ||
import { EventContext, FirebaseAdminApp } from '../firebase'; | ||
import { logger } from '../utils/logger'; | ||
|
||
const appEnv = new AppEnv().env; | ||
|
||
export const pubsubBackupFirestore = async (_context: EventContext, adminApp: FirebaseAdminApp) => { | ||
const projectID = adminApp.options.projectId; | ||
if (!projectID) { | ||
throw new AppError('missing projectID'); | ||
} | ||
|
||
const prefix = appEnv.firestoreBackup.bucketPrefix(); | ||
|
||
const client = new admin.firestore.v1.FirestoreAdminClient(); | ||
const databaseName = client.databasePath(projectID, '(default)'); | ||
|
||
logger.info('exportDocuments', { prefix }); | ||
|
||
return client.exportDocuments({ | ||
name: databaseName, | ||
outputUriPrefix: prefix, | ||
collectionIds: [], | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters