GPG is useful especially for signing commits on GitHub. It is a good idea to pre-emptively make backups of your GPG credentials, as extracting them from an unbootable system drive is not a straightforward process.
Backing up GPG
These steps should work on most, if not all, Linux distributions.
First, export your credentials
Afterwards, copy these 3 files
public.gpg
private.gpg
trust.gpg
to somewhere safe (like an external drive or NAS).You can import them on a new machine by running the following
...moreTip: For GitHub users, if you need to sign commits using your existing GPG key on your new machine, see https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key.