Closed pmarconi closed 1 year ago
@willhlaw is the enhancement in progress? it would be great to have it.
@VolodymyrPobochii @pmarconi, it was actually fixed in 1.2.1 on Feb 6.
I just confirmed. Document references are properly reconstructed when cloning from one firestore to another.
@willhlaw Great! Thanks so much!
@willhlaw I have just tried it out in versions 1.2.1, 1.3.1 and the error is still there. Any ideas?
Error! Restoring to collection /releases document ylMxpcTV13Tj5JzVbBP6 - Error: 3 INVALID_ARGUMENT: Reference value app: "arccompsdemo" PathElement { type: "versionCode" name: "kWuGZp1knaowVxgKgkxH" } in different app partition
hey @VolodymyrPobochii.
Yes, I tried this again with the latest changes in master, and I think you are right, the error still persists
There is a difference when a document is restored directly from the hard drive backup, being more specific, using the command:
firestore-backup-restore --backupPath backups-test --restoreAccountCredentials testing2-cred.json
and when you want to make a backup and restore a document at once, that is, using the command:
firestore-backup-restore --accountCredentials testing-cred.json --backupPath backups-test --restoreAccountCredentials testing2-cred.json
since the restoration in this second case is done trying to restore the document without being parsed before. See at backupCollection
function on the index.js, it calls the restoreDocument
function and this one try to save the document directly
I think the solution for this is change on the restoreDocument
function (index.js) the set
parameter like this
constructFirestoreDocumentObject(constructDocumentObjectToBackup(document.data()), { firestore: restoreAccountDb })
instead of document.data()
Like this:
!restoreAccountDb
? null
: restoreAccountDb
.collection(collectionName)
.doc(document.id)
.set(
constructFirestoreDocumentObject(
constructDocumentObjectToBackup(document.data()),
{ firestore: restoreAccountDb }
)
)
@VolodymyrPobochii If you need to go ahead with this, you can do the backup first, and then restore using separate commands, I think that should work, let me know how that works for you.
I will reopen this issue, and close the another one, to keep the discussion here
@willhlaw feel free to close this issue again
I'll accept a PR with an approach outlined above.
I currently get an error when wanting to restore a document that contains a document reference, using the command line
firestore-backup-restore --accountCredentials path/to/account/credentials/app1.json --backupPath /backups/myDatabase --restoreAccountCredentials path/to/restore/credentials/app2.json
In my tests, I get the following error
I think this error happens because we try to save a reference to a document belonging to another database