-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonetab_bak
62 lines (51 loc) · 2.25 KB
/
onetab_bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
die() { printf %s "${@+$@$'\n'}" 1>&2 ; exit 1 ; }
see() ( { set -x; } 2>/dev/null ; "$@" ) ;
# a (probably extremely brittle) script to backup OneTab Chrome browser extension's
# saved tabs (since rarely but at least a few times over the years, OneTab's stored
# tabs have been lost, and it's a significant loss when this happens).
#
# this may all be BACKUP THEATER as I have not tested restoration!!!
# I would PREFER a way to script the
# "'Export URLs' / click mouse in text field / Ctrl+A / save clipboard to a
# text file" UI sequence: LDB files are completely opaque to me (for all I
# know, they're encrypted for security), but this lies far outside my area of
# expertise (and is likely to be browser-specific knowledge of value to me
# nowhere else)
# todo:
# todo: Firefox
# todo: replace OneTab with a more suitable/reliable extension? (I use OneTab
# because it's simple and serves most of my needs, not because it's ideal...)
ts="$(date +'%y%m%dt%H%M%S')"
bakdest="${LOCALAPPDATA}/kevins-backup-OneTab/$ts"
mkdir -p "$bakdest" || die
bakfile() (
if [[ -f "$2" ]]; then
echo "backing up $1"
destdir="$bakdest/$1"
mkdir -p "$destdir" || die
cp "$2" "$destdir/" || die
fi
)
bakdir() (
tag="$1" ; shift
srcdnm="$1" ; shift
if [[ -d "$srcdnm" ]]; then
destdir="$bakdest/$tag"
echo "backing up $tag to $destdir"
mkdir -p "$destdir" || die
destfnm="${destdir}/$tag.7z"
echo "backing up $tag to $destfnm"
( cd "$srcdnm" && see 7z a "$destfnm" "$@" ) || die "7z failed"
fi
)
chrome_ish() (
# only *.ldb files are saved, because all others (except perhaps *.log files, which are of uncertain usefulness)
# are (potentially) held locked (cannot even be _read_) when Chrome is open.
bakdir "win-chrome" "${LOCALAPPDATA}/Google/Chrome/User Data/Default/Local Storage/leveldb" '-i!./*.ldb'
)
ffox_ish() ( # untested
bakfile "Firefox" "${APPDATA}\Mozilla\Firefox\Profiles\t71tluuq.default\jetpack\[email protected]\simple-storage\store.json"
bakfile "Cyberfox" "${APPDATA}\8pecxstudios\Cyberfox\Profiles\kjnvzpy8.default\jetpack\[email protected]\simple-storage\store.json"
)
chrome_ish