2017-05-26 19:51:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
backup)
|
|
|
|
# Backup the trustdb
|
|
|
|
gpg2 --export-ownertrust >.gnupg/trustdb.txt
|
2017-05-26 19:51:05 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
# Compile the archive
|
|
|
|
tar -cvjf - .gnupg/private-keys-v1.d .gnupg/pubring.gpg .gnupg/trustdb.gpg .gnupg/trustdb.txt | gpg2 --output ${HOME}/gnupg_backup.asc --symmetric --armor
|
|
|
|
;;
|
2017-05-26 19:51:05 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
restore)
|
2017-05-26 19:51:05 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
# Restore the archive
|
|
|
|
gpg2 --decrypt ${HOME}/gnupg_backup.asc | tar -xvj
|
2017-05-26 19:51:05 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
# Restore the owner-trust
|
|
|
|
gpg2 --import-ownertrust <.gnupg/trustdb.txt
|
|
|
|
;;
|
2017-05-26 19:51:05 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
*)
|
|
|
|
echo "Call me like this: $0 <backup | restore>"
|
|
|
|
exit 1
|
|
|
|
;;
|
2017-05-26 19:51:05 +00:00
|
|
|
|
|
|
|
esac
|