- commit
- 0384861
- parent
- 7e16a33
- author
- xxwhirlpool
- date
- 2026-03-29 14:15:23 -0400 EDT
add `keyback`
1 files changed,
+39,
-0
+39,
-0
1@@ -0,0 +1,39 @@
2+#!/usr/bin/env bash
3+
4+help_msg() {
5+ echo "Usage: keyback [OPTIONS]"
6+ echo "Options: --pgp | --ssh | --sync"
7+}
8+
9+if [[ $(hostname) == "mariposa" ]]; then # laptop
10+ input_dir=".mariposa_key_backup"
11+elif [[ $(hostname) == "kwangya" ]]; then # PC
12+ input_dir=".kwangya_key_backup"
13+fi
14+
15+target_dir="$HOME/$input_dir"
16+
17+make_target_dir() {
18+ [[ ! -d "$target_dir" ]]; mkdir "$target_dir" || echo "directory already exists, continuing..."
19+}
20+
21+backup_pgp_all() {
22+ make_target_dir
23+ gpg --export-secret-keys --armor --output "$target_dir"/gpg_all.asc
24+}
25+
26+backup_ssh_all() {
27+ make_target_dir
28+ tar cvzf "$target_dir"/ssh_all.tar.gz "$HOME"/.ssh
29+}
30+
31+sync_backups() {
32+ rsync -avzp "$target_dir" athena:/home/kat/backups/keys || echo "sync failed" && exit 1
33+}
34+
35+case "$1" in
36+ "") help_msg;;
37+ "--pgp") backup_pgp_all && sync_backups;;
38+ "--ssh") backup_ssh_all && sync_backups;;
39+ "--sync") sync_backups;;
40+esac