aboutsummaryrefslogtreecommitdiffstats
path: root/dot-backup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dot-backup.sh')
-rwxr-xr-xdot-backup.sh22
1 files changed, 21 insertions, 1 deletions
diff --git a/dot-backup.sh b/dot-backup.sh
index 5130012..0e22d70 100755
--- a/dot-backup.sh
+++ b/dot-backup.sh
@@ -214,11 +214,27 @@ do_restore() {
echo -e "${YELLOW}Restoring dotfiles from: ${BLUE}$DEFAULT_OUTPUT_DIR${NC}\n"
+ local system_skipped=0
+
for i in "${DOTFILES[@]}"; do
if beginswith "/" "$i"; then
- # system file
+ # system file — requires root
local backup_path="${DEFAULT_OUTPUT_DIR}/system/${i#/}"
local dest="$i"
+ if [[ "$EUID" -ne 0 ]]; then
+ if [[ -e "$backup_path" ]]; then
+ if [[ "$DRY_RUN" == true ]]; then
+ echo -e "${YELLOW}$dest${NC}"
+ echo -e "\t ${YELLOW}[dry-run] would restore: $backup_path → $dest (needs root)${NC}"
+ else
+ echo -e "${YELLOW}SKIP (needs root): $dest${NC}"
+ (( system_skipped++ )) || true
+ fi
+ else
+ log_verbose "\t ${YELLOW}SKIP (not in backup): $i${NC}"
+ fi
+ continue
+ fi
else
local backup_path="${DEFAULT_OUTPUT_DIR}/home/$i"
local dest="${HOME}/$i"
@@ -253,6 +269,10 @@ do_restore() {
fi
done
+ if [[ "$system_skipped" -gt 0 ]]; then
+ echo -e "\n${YELLOW}Warning: $system_skipped system file(s) skipped — re-run as root to restore them.${NC}"
+ fi
+
if [[ "$DRY_RUN" == true ]]; then
echo -e "\n${YELLOW}Dry run complete. Nothing restored.${NC}"
else