Replacement of mapdb by jsondb

FYI, I was able to use the REST API to backup and restore my items and links. I dumped my items and links out of my mapdb OH install via REST and stuck them in files (items.json & links.json).
I then whipped up a quick Node.js script to read the JSON dumps and then re-add my items and links to my jsondb OH install via REST.

Items:

var fs = require('fs');
var unirest = require('unirest');

var obj = JSON.parse(fs.readFileSync('items.json', 'utf8'));

obj.forEach(function(value){
  unirest.put(`http://openhab.local/rest/items/${value['name']}`)
  .auth({user: '', pass: '', sendImmediately: true})
  .type('json')
  .send(value)
  .end(function (response) {
    console.log(`${value.name} ${response.status}`);
  })
});

Links:

var fs = require('fs');
var unirest = require('unirest');

var obj = JSON.parse(fs.readFileSync('links.json', 'utf8'));

obj.forEach(function(value){
  unirest.put(`http://openhab.local/rest/links/${value['itemName']}/${value['channelUID']}`)
  .auth({user: '', pass: '', sendImmediately: true})
  .end(function (response) {
    console.log(`${value.itemName} ${response.status}`);
  })
});
3 Likes