rxw1 / sbh

Session Buddy (Backup) Helper
MIT License
9 stars 2 forks source link
backup backup-utility browser browser-extension extension-chrome session-management sessions

Session Buddy Helper

Command line tool to do various things with your Session Buddy database

What

Session Buddy is a Google Chrome extension to store and restore browser tabs. All its data is stored in a SQLite3 database. There is a Google Group where some discussion about Session Buddy takes place and, it seems, people sometimes lose their data or are having problems exporting or importing their stuff. This utility aims to do various operations on that database and help out those in need.

Features

Current State & Motivation

So far it seems to work.

Over the years I have aggregated multiple databases with in summary around 5,000 stored sessions consisting of around 15,000 windows and more than 130.0000 tabs. The extension would choke on exporting or just crash the extension or make the browser itself freeze. By doing all the stuff on the SQLite database itself, all that works.

But still, it may be not advisable to carry all your stuff around in a Chrome extension all the time. By scheduling regular backups and pruning operations on the database Session Buddy probably won't lose it and, you have convenient (and performant) access to all your data.

If you have any ideas or wishes regarding this tool or need help rescuing your thousands of tabs, feel free to reach out in the discussions.

Installation

cargo install sbh
git clone https://www.github.com/rxw1/sbh
cd sbh
cargo install --release .
curl -LSfs https://japaric.github.io/trust/install.sh |\
 sh -s -- --git rxw/sbh

Or download precompiled packages from here.

Usage Examples

Search for databases

Search for databases and print out the paths. By default, we're trying to figure out the proper path automatically depending on the operating system. For more information about these paths have a look at dirs-rs.

sbh search

Or you can pass any path to search there:

sbh search ~/.config

Backup a database to JSON

sbh backup -o whatever.json

If you do not specify an output file, the produced JSON will be printed to the standard output.

Search and backup each found database to a timestamped file

for db in "$(sbh search)"; do
  o=sb-$(sbh id $db)-$(date +%Y%m%d%H%M%S).json
  sbh backup -o $o $db
  sbh validate backup $o
done

Dump sort and count all URLs stored in a database

sbh search | while read -r l; do
  sbh dump "$l" | grep -Ev 'chrome(|-.*)://' | sort | uniq -c | sort -g
done

TODO (Maybe)

Is it any good?

Yes, of course. It is written in Rust, and it's blazingly fast.

Findings

* For whatever reason, the JSON backups produced by the extension have <feff> as the first byte, i.e. a BOM character aka Zero Width No-Break Space, which breaks it for most parsers. I don't think having this in the beginning of a JSON file is a good thing. After removal, everything is fine. Here's some discussion about that on Stack Overflow: https://stackoverflow.com/q/4990095/220472.

Disclaimer

Neither me or this tool is in any way affiliated with the developers of Session Buddy.

--

https://github.com/rxw1/sbh