Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created August 28, 2023 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrk/6019cd7cf5d8dd995be78a95817c9d1c to your computer and use it in GitHub Desktop.
Save andrewrk/6019cd7cf5d8dd995be78a95817c9d1c to your computer and use it in GitHub Desktop.
exfiltrate groove basin database to a JSON file
  1. drop db2json.js into your groovebasin instance
  2. stop your groove basin instance so that it does not write to the db while you are dumping its data
  3. node db2json.js (use the same node.js version as groove basin is using, and it also wants to use the same leveldown dependency you already have installed). It hard-codes the input as groovebasin.db.
  4. groovebasin.db.json is created which is 100% of the information from the database, in JSON format. It is one giant map of every key-value pair.
var fs = require('fs');
var path = require('path');
var leveldown = require('leveldown');
var defaultConfig = {
dbPath: "groovebasin.db",
};
main();
function main() {
var dbFilePath = "groovebasin.db";
var db = leveldown(dbFilePath);
db.open(function(err) {
if (err) throw err;
dbIterate(db, "", processOne, allDone);
var map = {};
function processOne(key, value) {
map[key] = value;
}
function allDone(err) {
if (err) throw err;
fs.writeFile("groovebasin.db.json", JSON.stringify(map), function(err) {
if (err) throw err;
process.exit(0);
});
}
function deserializeUser(payload) {
return JSON.parse(payload);
}
});
}
function dbIterate(db, keyPrefix, processOne, cb) {
var it = db.iterator({
gte: keyPrefix,
keyAsBuffer: false,
valueAsBuffer: false,
});
itOne();
function itOne() {
it.next(function(err, key, value) {
if (err) {
it.end(onItEndErr);
cb(err);
return;
}
if (!key || key.indexOf(keyPrefix) !== 0) {
it.end(cb);
} else {
processOne(key, value);
itOne();
}
});
}
}
function onItEndErr(err) {
if (err) throw err;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment