Skip to content

Instantly share code, notes, and snippets.

@schnatterer
Created November 12, 2021 21:00
Show Gist options
  • Save schnatterer/e7a5b70617f1b9742c4cb848d836d6bf to your computer and use it in GitHub Desktop.
Save schnatterer/e7a5b70617f1b9742c4cb848d836d6bf to your computer and use it in GitHub Desktop.
Restore android call logs

Restoring android call logs backed up via myPhoneExplorer (unable to restore with Android 11) using a different app (Phone Backup and Restore).

  • Export all call logs from myPhoneExplorer as CSV (Tested with version 1.9.0)
  • Check out mpe-csv-2-json.js and package.json from this gist
  • npm install
  • ./mpe-csv-2-json.js your.csv > 2021-10-24, 09:02:25.sbl
  • Copy the .sbl file to where "Phone Backup and Restore" can read it. In Version 1.6.6 it's /storage/emulated/0/Android/data/com.phone.backup.restore/files/ (which requires root to access :-/)
  • Open Backup and restore app and restore your call logs file
#!/usr/bin/env node
const fs = require('fs');
const csv = require('csv-parser');
const moment = require('moment');
const out = {};
out.f = []
function storageToE(Storage) {
// RC = Received Call? -> 1
// DC = Dialed Call ?-> 2
// MC = Missed Call? -> 3
if (Storage=== 'RC') {
return 1
}
if (Storage=== 'DC') {
return 2
}
if (Storage ==='MC') {
return 3
}
throw `unknown Storage: ${Storage}`
}
if (process.argv.length <= 2) {
console.log("Usage: " + __filename + " <input.csv>");
process.exit(-1);
}
fs.createReadStream(process.argv[2])
.pipe(csv({ separator: ';' }))
.on('data', function(data){
try {
let call = {};
call.a = data.Nummer
call.b = data.Name
call.c = moment(data.Zeitpunkt, "DD.MM.YYYY hh:mm").valueOf();
call.d = data.Dauer
call.e = storageToE(data.Storage)
out.f.push(call)
}
catch(err) {
throw err;
}
})
.on('end',function(){
let str = JSON.stringify(out);
str = JSON.stringify(out, null, 4); // (Optional) beautiful indented output.
console.log(str);
});
{
"name": "mpe-csv-2-json",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"csv-parser": "^3.0.0",
"moment": "^2.29.1"
},
"devDependencies": {}
},
"node_modules/csv-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz",
"integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==",
"dependencies": {
"minimist": "^1.2.0"
},
"bin": {
"csv-parser": "bin/csv-parser"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
}
},
"dependencies": {
"csv-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz",
"integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==",
"requires": {
"minimist": "^1.2.0"
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
}
}
}
{
"name": "mpe-csv-2-json",
"version": "1.0.0",
"description": "",
"main": "mpe-csv-2-json.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"csv-parser": "^3.0.0",
"moment": "^2.29.1"
},
"devDependencies": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment