-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·59 lines (46 loc) · 1.75 KB
/
backup.sh
File metadata and controls
executable file
·59 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -e
eval $(op signin) &>/dev/null
TMP_DIR=$(mktemp -d)
echo "Starting Backup."
# Save GPG Secrets
gpg -a --export >"$TMP_DIR/pubkeys.asc" &>/dev/null
gpg -a --export-secret-keys >"$TMP_DIR/privatekeys.asc" &>/dev/null
gpg --export-ownertrust >"$TMP_DIR/trust.txt" &>/dev/null
update_or_create() {
local doc_name="$1"
local file_path="$2"
if op document get "$doc_name" &>/dev/null; then
op document edit "$doc_name" "$file_path" &>/dev/null
else
op document create "$file_path" --title "$doc_name" &>/dev/null
fi
}
update_or_create "GPG Private Keys" "$TMP_DIR/privatekeys.asc"
update_or_create "GPG Public Keys" "$TMP_DIR/pubkeys.asc"
update_or_create "GPG TrustDB" "$TMP_DIR/trust.txt"
# Clean up the temporary files
rm -rf "$TMP_DIR"
# Update Brewfile
BrewfilePath="$HOME/.local/share/chezmoi/Brewfile"
brew bundle dump --file="$BrewfilePath" --force
# Backup my Developer directory to iCloud.
DEV_DIR="$HOME/Developer"
ZIP_PATH="$HOME/Documents/dev_backup.zip"
cd "$DEV_DIR"
zip -r "$ZIP_PATH" . &>/dev/null
ICLOUD_DOCS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Documents"
if [ -d "$ICLOUD_DOCS" ]; then
mv "$ZIP_PATH" "$ICLOUD_DOCS/Backup/dev_backup.zip"
fi
# Backup Dock and LaunchPad Preferences
lporg save --icloud &>/dev/null
# Backup App Preferences
APP_PREFS_DIR="$ICLOUD_DOCS/Backup/AppPreferences"
mkdir -p "$APP_PREFS_DIR"
defaults export com.lwouis.alt-tab-macos "$APP_PREFS_DIR/alttab.plist"
defaults export com.if.Amphetamine "$APP_PREFS_DIR/amphetamine.plist"
defaults export pl.maketheweb.cleanshotx "$APP_PREFS_DIR/cleanshotx.plist"
defaults export com.knollsoft.Rectangle "$APP_PREFS_DIR/rectangle.plist"
defaults export com.raycast.macos "$APP_PREFS_DIR/raycast.plist"
echo "Backup Complete."