Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created July 7, 2023 00:13
Show Gist options
  • Save psyomn/a1b18c02102019d04b1eb9acd0a8fda2 to your computer and use it in GitHub Desktop.
Save psyomn/a1b18c02102019d04b1eb9acd0a8fda2 to your computer and use it in GitHub Desktop.
Backup Opera Sessions

backup opera sessions

Decided to leave this for anyone else that may be having issues.

I switched from firefox to opera recently.

I gave Opera a shot after something like 10 years to see how the browser is faring. I'm enjoying the workflow. I can have workspaces, and combine them with tab islands, which makes organization very possible.

However, it seems Opera likes to crash often (I've observed this on my computer running Linux, as well as on Windows), which is OK, since it comes back up fast, but sometimes it completely erases the tabs in all workspaces.

With a little bit of guesswork, and searching online I found out that sessions (that is all your tabs, all workspaces) are stored in $HOME/.config/opera/Sessions. The format of the files are apparently snss format, which https://github.com/lemnos/chrome-session-dump has probably a better explanation/breakdown of it. (You can also run a hex editor or strings against these files if you just want to get some of your urls back, though the output is not perfect).

That being said, I decided to simply write a user systemd timer, that calls the posted bash script. The bash script will attempt to append your opera sessions in a zip file. The zip file is located in $HOME/Documents/opera-sessions-backup.zip.

The session files will have a timestamp at the end of the file (NB: you want the Session_* files), which should hint at when the session was dumped in the disk.

The systemd timer, I set it to call this bash script every 3 hours. You migh want to tweak that for yourself.

you should be able to add these to your user with

systemctl --user enable backup-opera-tabs.service
systemctl --user enable backup-opera-tabs.timer
systemctl --user daemon-reload

I personally have the script for the zip file in ~/.local/bin/ but you should decide if that's right for you.

[Unit]
Description=opera tabs backup script
[Service]
Type=oneshot
ExecStart=/bin/bash %h/.local/bin/backup-opera-tabs.sh
#!/usr/bin/env bash
BACKUPFILE="$HOME/Documents/opera-sessions-backup.zip"
zip \
-u9r "$BACKUPFILE" \
"$HOME/.config/opera/Sessions/"
[Unit]
Description=run the opera backup
[Timer]
OnUnitActiveSec=3h
OnBootSec=3h
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment