From 5257486b002857b21de9ff198310e375042d34fc Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sat, 10 Sep 2022 12:19:21 +0300
Subject: [PATCH] Firefox backup and restore scripts.

---
 Documents/bin/ff-backup  | 17 +++++++++++++++++
 Documents/bin/ff-restore | 15 +++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100755 Documents/bin/ff-backup
 create mode 100755 Documents/bin/ff-restore

diff --git a/Documents/bin/ff-backup b/Documents/bin/ff-backup
new file mode 100755
index 0000000..b1ea595
--- /dev/null
+++ b/Documents/bin/ff-backup
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -eu
+
+if flatpak ps --columns=application | grep --silent --fixed-strings 'org.mozilla.firefox'
+then
+    echo 'Firefox is running, aborting backup.' >&2
+    exit 1
+fi
+
+ff_home="$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox"
+profile="$(awk -F '=' '$1 == "Path" {print $2}' "$ff_home/profiles.ini" | xargs)"
+
+exec tar --directory "$ff_home" \
+    --create \
+    --zstd \
+    "--file=$HOME/Documents/ff-backup.tar.zstd" \
+    profiles.ini "$profile"
diff --git a/Documents/bin/ff-restore b/Documents/bin/ff-restore
new file mode 100755
index 0000000..38fecd0
--- /dev/null
+++ b/Documents/bin/ff-restore
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -eu
+
+if flatpak ps --columns=application | grep --silent --fixed-strings 'org.mozilla.firefox'
+then
+    echo 'Firefox is running, aborting restore.' >&2
+    exit 1
+fi
+
+ff_home="$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox"
+
+exec tar --directory "$ff_home" \
+    --extract \
+    --zstd \
+    "--file=$HOME/Documents/ff-backup.tar.zstd"
-- 
GitLab