Skip to content

Instantly share code, notes, and snippets.

@thornomad
thornomad / gpg-import-and-export-instructions.md
Created Apr 18, 2020 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys
View gpg-import-and-export-instructions.md

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.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
# or, instead of backing up trustdb...
View rails-6-test.log
(499.2ms) CREATE DATABASE "test_app_6_test" ENCODING = 'unicode'
(19.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
(7.6ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
(0.2ms) SELECT pg_try_advisory_lock(6568561817215537440)
(0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Migrating to CreateTableAndViewForTesting (20200122031151)
(0.2ms) BEGIN
(3.6ms) CREATE TABLE "people" ("id" bigserial primary key, "name" character varying)
(0.9ms) DROP VIEW IF EXISTS view_people;
CREATE OR REPLACE VIEW view_people AS
You can’t perform that action at this time.