blob: 9b80d5fb8b207e4d497ee76e9c6b1039a22ec803 (
plain)
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
|
#!/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
|