aboutsummaryrefslogtreecommitdiffstats
path: root/bin/backup-profiles
blob: 57a7d031222aacb6859556c64403d6ce9dd0c56a (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
#!/bin/sh

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 |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 $thunderbirdIF
  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