aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2015-03-19 02:21:42 +0100
committerDavid Runge <dave@sleepmap.de>2015-03-19 02:21:42 +0100
commitcd15d76a6a2cabe9aabe27b6937e08c4ce22ab88 (patch)
tree99602d7ed366696d731aad8549690b2247516b38 /scripts
parent78d8d16814f3faa1ff6d5c87a1d215907b991069 (diff)
downloadcrypted-backups-cd15d76a6a2cabe9aabe27b6937e08c4ce22ab88.tar.gz
crypted-backups-cd15d76a6a2cabe9aabe27b6937e08c4ce22ab88.tar.bz2
crypted-backups-cd15d76a6a2cabe9aabe27b6937e08c4ce22ab88.tar.xz
crypted-backups-cd15d76a6a2cabe9aabe27b6937e08c4ce22ab88.zip
scripts/backup-{firefox,thunderbird}: Adding first version of backup scripts for Firefox and Thunderbird.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/backup-firefox58
-rwxr-xr-xscripts/backup-thunderbird46
2 files changed, 104 insertions, 0 deletions
diff --git a/scripts/backup-firefox b/scripts/backup-firefox
new file mode 100755
index 0000000..9b80d5f
--- /dev/null
+++ b/scripts/backup-firefox
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+profiles=( ) # List of profiles
+timestamp="$(date +"%Y%m%d-%H%M%S")-"
+user_name=$(whoami)
+user="$user_name/"
+firefox_pid=$(ps -C firefox u | grep $user_name | awk '{print $2}') # Current Firefox pid
+psd=$(systemctl is-active psd) # psd activation
+
+# If the backup location doesn't exist yet, create it
+if [ ! -d $firefox_folder_destination ]; then
+ mkdir -p $firefox_folder_destination
+fi
+
+# If the parent directory of the backup source exists, enter it
+if [ -d $home$user$firefox_folder_source ]; then
+ cd $home$user$firefox_folder_source
+else
+ exit 1
+fi
+
+# Check, if Firefox is not running
+if [[ -z "$firefox_pid" ]]; then
+ for subfolder in $home$user$firefox_folder_source*
+ do
+ subfolder=$(basename $subfolder)
+ if [[ $subfolder != Crash* ]] && [[ $subfolder != profiles.ini ]] && [[ $subfolder != *-backup ]]; then
+ profiles=( ${profiles[@]} $subfolder )
+ fi
+ done
+else
+ # Check, if psd is active
+ if [[ $psd = "active" ]]; then
+ for subfolder in $home$user$firefox_folder_source*
+ do
+ subfolder=$(basename $subfolder)
+ if [[ $subfolder != Crash* ]] && [[ $subfolder != profiles.ini ]] && [[ $subfolder = *-backup ]]; then
+ profiles=( ${profiles[@]} $subfolder )
+ fi
+ done
+ else
+ echo "Firefox is still running. Skipping backup."
+ fi
+fi
+
+for profile in $profiles
+do
+ echo "$profile --> $firefox_folder_destination$timestamp$profile$tar_suffix$gpg_suffix"
+ # tar to /tmp
+ tar cfJ $tmp$timestamp$profile$tar_suffix -h $profile
+ # gpg to backup location
+ gpg -e \
+ -r "$gpg_public_key" \
+ -o "$firefox_folder_destination$timestamp$profile$tar_suffix$gpg_suffix" \
+ $tmp$timestamp$profile$tar_suffix
+ # remove tar in /tmp
+ rm -f $tmp$timestamp$profile$tar_suffix
+done
diff --git a/scripts/backup-thunderbird b/scripts/backup-thunderbird
new file mode 100755
index 0000000..ca67b72
--- /dev/null
+++ b/scripts/backup-thunderbird
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+profiles=( ) # List of profiles
+timestamp="$(date +"%Y%m%d-%H%M%S")-"
+user_name=$(whoami)
+user="$user_name/"
+thunderbird_pid=$(ps -C thunderbird u | grep $user_name | awk '{print $2}') # Current thunderbird pid
+
+# If the backup location doesn't exist yet, create it
+if [ ! -d $thunderbird_folder_destination ]; then
+ mkdir -p $thunderbird_folder_destination
+fi
+
+# If the parent directory of the backup source exists, enter it
+if [ -d $home$user$thunderbird_folder_source ]; then
+ cd $home$user$thunderbird_folder_source
+else
+ exit 1
+fi
+
+# Check, if thunderbird is not running
+if [[ -z "$thunderbird_pid" ]]; then
+ for subfolder in $home$user$thunderbird_folder_source*
+ do
+ subfolder=$(basename $subfolder)
+ if [[ $subfolder != Crash* ]] && [[ $subfolder != profiles.ini ]] && [[ $subfolder != *-backup ]]; then
+ profiles=( ${profiles[@]} $subfolder )
+ fi
+ done
+else
+ echo "thunderbird is still running. Skipping backup."
+fi
+
+for profile in $profiles
+do
+ echo "$profile --> $thunderbird_folder_destination$timestamp$profile$tar_suffix$gpg_suffix"
+ # tar to /tmp
+ tar cfJ $tmp$timestamp$profile$tar_suffix -h $profile
+ # gpg to backup location
+ gpg -e \
+ -r "$gpg_public_key" \
+ -o "$thunderbird_folder_destination$timestamp$profile$tar_suffix$gpg_suffix" \
+ $tmp$timestamp$profile$tar_suffix
+ # remove tar in /tmp
+ rm -f $tmp$timestamp$profile$tar_suffix
+done