Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.
gpg --export --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.pub.asc
gpg --export-secret-keys --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.priv.asc
gpg --export-secret-subkeys --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.sub_priv.asc
gpg --export-ownertrust > ownertrust.txt
gpg --import 1E0B5331219BEA88.pub.asc
gpg --import 1E0B5331219BEA88.priv.asc
gpg --import 1E0B5331219BEA88.sub_priv.asc
gpg --import-ownertrust ownertrust.txt
This is so that I can encrypt data using my public key
gpg --edit-key 1E0B5331219BEA88
gpg> trust
Your decision? 5 (Ultimate trust)
NOTE If I don't trust the public key then I see the following message when trying to encrypt something with it:
gpg: <key-id>: There is no assurance this key belongs to the named user