Backup: targeted fast snapshot by default; full config via DEO_BACKUP_FULL=1
swadhinbiswas committed 2 months ago
61c9fbe
1 parent c136460
commit 61c9fbe
2 files changed
+44 -36
Showing 2 changed files+44-36
▼install.sh
+8-2
| @@ -55,8 +55,9 @@ cat <<BANNER | ||
55 | 55 | de-omarchy — apply the Omarchy desktop look on top of $(printf '%s' "${PRETTY_NAME:-this system}") |
56 | 56 | |
57 | 57 | What happens: |
58 | - 1. Full backup of ~/.config, dotfiles, ssh, zsh, package lists | |
59 | - -> $BACKUP_ROOT/<timestamp>/ (never inside this repo) | |
58 | + 1. TARGETED backup (seconds): every file this installer could touch, | |
59 | + plus .ssh / zsh stack / starship — -> $BACKUP_ROOT/<timestamp>/ | |
60 | + (add DEO_BACKUP_FULL=1 to also snapshot all of ~/.config) | |
60 | 61 | 2. Missing UI packages installed (system layer untouched) |
61 | 62 | 3. Runtime deployed to $RUNTIME |
62 | 63 | 4. Additive user config hooks installed: |
| @@ -66,6 +67,11 @@ cat <<BANNER | ||
66 | 67 | your .zshrc already sources this dir — zero edits to .zshrc) |
67 | 68 | 5. Omarchy state initialized + rose-pine theme applied |
68 | 69 | |
70 | + NOTHING in your home directory is ever deleted or overwritten: | |
71 | + * new files are only ADDED (symlinks into this repo) | |
72 | + * hyprland.lua gets one clearly-marked block APPENDED; a timestamped | |
73 | + copy of it is saved next to it first | |
74 | + * existing ~/.config/omarchy state is merged with --ignore-existing | |
69 | 75 | NOT touched: .zshrc/.zshenv/starship.toml/kitty.conf/ssh keys, pacman.conf, |
70 | 76 | mirrors, kernel, bootloader, display manager, monitors layout. |
71 | 77 | |
72 | 78 | |
▼scripts/backup.sh
+36-34
| @@ -1,65 +1,67 @@ | ||
1 | 1 | #!/bin/bash |
2 | -# de-omarchy backup — COPIES ONLY. Never deletes, moves or overwrites anything. | |
3 | -# Writes to $DEO_BACKUP_ROOT (default ~/.de-omarchy-backups), outside the repo. | |
2 | +# de-omarchy backup — COPIES ONLY, deletes/moves/overwrites nothing. | |
3 | +# | |
4 | +# Default: TARGETED snapshot of exactly the paths install.sh may touch plus | |
5 | +# critical identity files (seconds, a few MB). | |
6 | +# Set DEO_BACKUP_FULL=1 to additionally rsync ALL of ~/.config (slow). | |
4 | 7 | set -u |
5 | 8 | |
6 | 9 | TS=$(date +%Y%m%d-%H%M%S) |
7 | 10 | BACKUP_ROOT="${DEO_BACKUP_ROOT:-$HOME/.de-omarchy-backups}/$TS" |
8 | -mkdir -p "$BACKUP_ROOT" | |
11 | +mkdir -p "$BACKUP_ROOT/dotfiles" | |
9 | 12 | LOG="$BACKUP_ROOT/backup.log" |
10 | 13 | log() { echo "[backup $TS] $*" >> "$LOG"; } |
11 | 14 | |
12 | -log "START config rsync" | |
13 | -rsync -aHAX --stats "$HOME/.config/" "$BACKUP_ROOT/config/" >> "$LOG" 2>&1 | |
14 | -log "DONE config rc=$?" | |
15 | +# --- 1. Config paths the installer can touch (small, complete copies) ------- | |
16 | +for d in hypr zshrc.d kitty quickshell moonrice moonshell; do | |
17 | + [[ -d $HOME/.config/$d ]] && rsync -a "$HOME/.config/$d" "$BACKUP_ROOT/config/" | |
18 | +done | |
19 | +for f in starship.toml; do | |
20 | + [[ -f $HOME/.config/$f ]] && cp -a "$HOME/.config/$f" "$BACKUP_ROOT/config/" | |
21 | +done | |
22 | +log "DONE targeted config" | |
15 | 23 | |
16 | -# Shell & identity dotfiles | |
17 | -mkdir -p "$BACKUP_ROOT/dotfiles" | |
18 | -for f in .zshrc .zshenv .zprofile .zlogin .zlogout .bashrc .bash_profile .bash_logout \ | |
19 | - .p10k.zsh .gitconfig .gitignore_global .tmux.conf .profile; do | |
24 | +# --- 2. Shell & identity dotfiles ------------------------------------------- | |
25 | +for f in .zshrc .zshenv .zprofile .zlogin .zlogout .bashrc .bash_profile \ | |
26 | + .p10k.zsh .gitconfig .profile; do | |
20 | 27 | [[ -e $HOME/$f ]] && cp -a "$HOME/$f" "$BACKUP_ROOT/dotfiles/" |
21 | 28 | done |
22 | 29 | [[ -d $HOME/.zshrc.d ]] && rsync -a "$HOME/.zshrc.d/" "$BACKUP_ROOT/dotfiles/zshrc.d/" |
23 | -[[ -d $HOME/.ssh ]] && { mkdir -p "$BACKUP_ROOT/dotfiles/.ssh"; rsync -a "$HOME/.ssh/" "$BACKUP_ROOT/dotfiles/.ssh/"; chmod 700 "$BACKUP_ROOT/dotfiles/.ssh"; chmod 600 "$BACKUP_ROOT"/dotfiles/.ssh/* 2>/dev/null; } | |
30 | +[[ -d $HOME/.ssh ]] && { mkdir -p "$BACKUP_ROOT/dotfiles/.ssh"; rsync -a --exclude='agent/' --exclude='*.agent.*' "$HOME/.ssh/" "$BACKUP_ROOT/dotfiles/.ssh/"; chmod 700 "$BACKUP_ROOT/dotfiles/.ssh"; chmod 600 "$BACKUP_ROOT"/dotfiles/.ssh/* 2>/dev/null; } | |
24 | 31 | log "DONE dotfiles" |
25 | 32 | |
26 | -# Relevant ~/.local/share subfolders only (themes, fonts, app data stays out) | |
27 | -for d in applications fonts icons themes backgrounds sounds wayland hypr swww matugen color-schemes wallpapers; do | |
28 | - [[ -d $HOME/.local/share/$d ]] && rsync -a "$HOME/.local/share/$d" "$BACKUP_ROOT/local-share/" | |
29 | -done | |
30 | -log "DONE local-share relevant" | |
33 | +# --- 3. Optional full ~/.config sweep ---------------------------------------- | |
34 | +if [[ ${DEO_BACKUP_FULL:-0} == 1 ]]; then | |
35 | + log "START full config rsync" | |
36 | + rsync -aHAX --stats "$HOME/.config/" "$BACKUP_ROOT/full-config/" >> "$LOG" 2>&1 | |
37 | + log "DONE full config rc=$?" | |
38 | +fi | |
31 | 39 | |
32 | -# Package manifests | |
33 | -pacman -Qq > "$BACKUP_ROOT/pkg-manifest-all.txt" 2>/dev/null | |
34 | -pacman -Qqe > "$BACKUP_ROOT/pkg-manifest-explicit.txt" 2>/dev/null | |
35 | -pacman -Qqm > "$BACKUP_ROOT/pkg-manifest-foreign-AUR.txt" 2>/dev/null | |
36 | -flatpak list --app --columns=application > "$BACKUP_ROOT/pkg-manifest-flatpak.txt" 2>/dev/null || true | |
37 | -log "DONE package manifests" | |
40 | +# --- 4. Package manifests ----------------------------------------------------- | |
41 | +pacman -Qqe > "$BACKUP_ROOT/pkg-manifest-explicit.txt" 2>/dev/null | |
42 | +pacman -Qqm > "$BACKUP_ROOT/pkg-manifest-foreign-AUR.txt" 2>/dev/null | |
38 | 43 | |
39 | -# Environment fingerprint | |
44 | +# --- 5. Fingerprint ------------------------------------------------------------ | |
40 | 45 | { |
41 | 46 | echo "# de-omarchy backup fingerprint — $(date)" |
42 | - echo "## kernel"; uname -a | |
43 | - echo "## os-release"; cat /etc/os-release | |
44 | - echo "## session"; echo "XDG_SESSION_TYPE=$XDG_SESSION_TYPE XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP SHELL=$SHELL" | |
45 | - echo "## display-manager"; systemctl status display-manager.service --no-pager 2>&1 | head -4 | |
46 | - echo "## hyprctl monitors"; hyprctl monitors all 2>/dev/null | |
47 | + uname -a | |
48 | + grep PRETTY_NAME /etc/os-release | |
49 | + echo "session: $XDG_SESSION_TYPE / $XDG_CURRENT_DESKTOP" | |
50 | + hyprctl monitors all 2>/dev/null | grep -E '^Monitor|^\t[0-9]+x[0-9]+@' | |
47 | 51 | } > "$BACKUP_ROOT/fingerprint.txt" 2>&1 |
48 | 52 | |
49 | -# Small critical bundle for quick restore | |
53 | +# --- 6. One-file restore bundle -------------------------------------------------- | |
50 | 54 | tar czf "$BACKUP_ROOT/critical-small.tar.gz" \ |
51 | 55 | -C "$HOME" \ |
52 | 56 | .ssh .zshrc .zshenv .zprofile .bashrc .gitconfig .zshrc.d \ |
53 | - .config/starship.toml .config/hypr .config/zshrc.d \ | |
57 | + .config/hypr .config/zshrc.d .config/starship.toml \ | |
54 | 58 | 2>> "$LOG" || true |
55 | 59 | sha256sum "$BACKUP_ROOT/critical-small.tar.gz" > "$BACKUP_ROOT/critical-small.sha256" |
56 | 60 | |
57 | -# Verification summary | |
58 | 61 | { |
59 | 62 | echo "== VERIFICATION $TS ==" |
60 | - du -sh "$BACKUP_ROOT/config" "$BACKUP_ROOT/dotfiles" "$BACKUP_ROOT/local-share" 2>/dev/null | |
63 | + du -sh "$BACKUP_ROOT" 2>/dev/null | |
61 | 64 | echo "file count: $(find "$BACKUP_ROOT" -type f | wc -l)" |
62 | - echo "critical tar: $(stat -c%s "$BACKUP_ROOT/critical-small.tar.gz") bytes" | |
63 | 65 | } >> "$LOG" |
64 | 66 | |
65 | -echo "Backup complete: $BACKUP_ROOT" | |
67 | +echo "Backup complete: $BACKUP_ROOT ($(du -sh "$BACKUP_ROOT" | cut -f1))" | |
66 | 68 | |