#!/usr/bin/env bash profiles=( ) # List of profiles timestamp="$(date +"%Y%m%d-%H%M%S")-" user_name=$(whoami) user="$user_name/" home="/home/" 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