- drop db2json.js into your groovebasin instance
- stop your groove basin instance so that it does not write to the db while you are dumping its data
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 asgroovebasin.db
.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.
Created
August 28, 2023 19:00
-
-
Save andrewrk/6019cd7cf5d8dd995be78a95817c9d1c to your computer and use it in GitHub Desktop.
exfiltrate groove basin database to a JSON file
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 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