fix(uninstall): MANDATORY tar backup in ALL modes (safe/settings-only/full)
Per user demand after data loss incident: never trust mode flags alone. Previously only `full` mode created tar.gz backup. Now `safe` and `settings-only` also create full tar.gz of ~/.claude (resp .codex, .gemini, .qwen) BEFORE any mutation. If backup fails, refuse to proceed for that user — skip to next. Restore is always one command: tar -xzf ~/.<tool>.uninstall-backup.<TS>.tar.gz -C ~ Applies to all 4 scripts: uclaude, ucodex, ugemini, uqwen. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -113,8 +113,20 @@ fi
|
||||
|
||||
# ---- Remove config ----
|
||||
|
||||
for user_home in "${_home_dirs[@]}"; do CODEX_DIR="$user_home/.codex"
|
||||
for user_home in "${_home_dirs[@]}"; do
|
||||
CODEX_DIR="$user_home/.codex"
|
||||
if [ -d "$CODEX_DIR" ]; then
|
||||
# ALWAYS create full tar backup BEFORE any destructive op, in EVERY mode.
|
||||
# Per user demand after data loss incident: never trust mode flags alone.
|
||||
FULL_BAK="$user_home/.codex.uninstall-backup.$TIMESTAMP.tar.gz"
|
||||
echo " Creating safety backup: $FULL_BAK ..."
|
||||
if ! tar -czf "$FULL_BAK" -C "$user_home" .codex 2>/dev/null; then
|
||||
echo " ERROR: backup FAILED for $CODEX_DIR — REFUSING to proceed (data preserved)"
|
||||
continue
|
||||
fi
|
||||
echo " Safety backup: $FULL_BAK ($(du -h "$FULL_BAK" 2>/dev/null | awk '{print $1}'))"
|
||||
echo " Restore anytime: tar -xzf $FULL_BAK -C $user_home"
|
||||
|
||||
# PRESERVE user data by default. See uclaude_uninstall.sh history.
|
||||
case "${MODE:-safe}" in
|
||||
safe)
|
||||
@@ -137,14 +149,8 @@ for user_home in "${_home_dirs[@]}"; do CODEX_DIR="$user_home/.codex"
|
||||
done
|
||||
;;
|
||||
full)
|
||||
BAK="$user_home/.codex.uninstall-backup.$TIMESTAMP.tar.gz"
|
||||
if tar -czf "$BAK" -C "$user_home" .codex 2>/dev/null; then
|
||||
echo " Backup: $BAK"
|
||||
rm -rf "$user_home/.codex"
|
||||
echo " Removed $user_home/.codex (restore: tar -xzf $BAK -C $user_home)"
|
||||
else
|
||||
echo " ERROR: backup failed — refusing to delete $user_home/.codex"
|
||||
fi
|
||||
rm -rf "$user_home/.codex"
|
||||
echo " Removed $user_home/.codex (full wipe)"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user