Last active
April 20, 2021 17:19
-
-
Save davideast/cdb3d45b4ece47760ae2 to your computer and use it in GitHub Desktop.
Transfer data from one Firebase database to another
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
var client = require('firebase-tools'); | |
function transfer(path, options) { | |
var fromDb = options.fromDb; | |
var toDb = options.toDb; | |
var output = options.output; | |
client.data.get(path, { firebase: fromDb, output: output }) | |
.then(function(data) { | |
return client.data.set(path, output, { firebase: toDb, confirm: true }); | |
}) | |
.then(function(data) { | |
console.log('transferred!'); | |
process.exit(1); | |
}) | |
.catch(function(error) { | |
console.log(error); | |
process.exit(2); | |
}); | |
} | |
transfer('/', { fromDb: '<from-db>', toDb: '<to-db>', output: 'test.json' }); |
@cmcowan I was wondering if you had any luck with this. I have a dataset over 700MB that I'd like to periodically copy from one project to another and found that both firebase-import and firebase-streaming-import would fail after several hours and GBs of usage.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi David, before I burn up a good chunk of data usage trying...do you think this transfer function is capable of transferring a large dataset ~400mb? I've burned thru several GB of usage trying to get the firebase-import and firebase-streaming-import to do this very thing but they fail after a large chunk has transferred and/or it just hangs endlessly. Appreciate all you do for the firebase community. -Chris