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 hidden or 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' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.