Skip to content

Instantly share code, notes, and snippets.

@davideast
Last active April 20, 2021 17:19
Show Gist options
  • Save davideast/cdb3d45b4ece47760ae2 to your computer and use it in GitHub Desktop.
Save davideast/cdb3d45b4ece47760ae2 to your computer and use it in GitHub Desktop.
Transfer data from one Firebase database to another
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
Copy link

cmcowan commented Jul 6, 2017

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

@amenon
Copy link

amenon commented Apr 18, 2018

@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