aboutsummaryrefslogtreecommitdiffstats
path: root/bin/backup-profiles
blob: db3dc66f07aafe7a51dd9c2b57164055b24cfbe0 (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
59
60
61
62
63
64
65
#!/bin/sh
#
# Backup profiles of firefox and thunderbird to local Dropbox (or other location) while encrypting them using gpg
#

firefoxPID=`ps -C firefox -o pid=`
thunderbirdPID=`ps -C thunderbird -o pid=`

firefoxTMP=/tmp/firefox.tgz
thunderbirdTMP=/tmp/thunderbird.tgz
firefoxIF=~/.mozilla/firefox/
thunderbirdIF=~/.thunderbird/
profileName=dvzrv
backupEND=-backup
OF=~/Dropbox/sync
gpgEND=.gpg


if [[ -z "$firefoxPID" ]]
then
  echo "Firefox is not running."
  echo "Backing up profile."
  tar cfPzh $firefoxTMP -C $firefoxIF $profileName
  echo "Encrypting profile."
  gpg -e -r 'David Runge <david.runge@frqrec.com>' $firefoxTMP
  echo "Moving backup to Dropbox."
  mv -f $firefoxTMP$gpgEND $OF
  echo "Cleaning up."
  rm $firefoxTMP
  echo "Done."
else
  echo "Firefox is still running."
  psdStopped=`systemctl status psd |grep inactive`
  if [[ ! -z "$psdStopped" ]]; then
    echo "psd service running. Trying to use its backup."
    tar cfPzh $firefoxTMP -C $firefoxIF $profileName$backupEND
    echo "Encrypting profile."
    gpg -e -r 'David Runge <david.runge@frqrec.com>' $firefoxTMP
    echo "Moving backup to Dropbox."
    mv -f $firefoxTMP$gpgEND $OF
    echo "Cleaning up."
    rm $firefoxTMP
    echo "Done."
  else
    echo "Skipping backup."
  fi
fi

if [[ -z "$thunderbirdPID" ]]
then
  echo "Thunderbird is not running."
  echo "Backing up profile."
  tar cfPz $thunderbirdTMP -C $thunderbirdIF $profileName
  echo "Encrypting profile."
  gpg -e -r 'David Runge <david.runge@frqrec.com>' $thunderbirdTMP
  echo "Moving backup to Dropbox."
  mv -f $thunderbirdTMP$gpgEND $OF
  echo "Cleaning up."
  rm $thunderbirdTMP
  echo "Done."
else
  echo "Thunderbird is still running."
  echo "Skipping backup."
fi