Skip to content

Commit 992ea29

Browse files
committed
Properly fix userdata backup exclusions, thanks to @Myself5!
1 parent 6cc53e3 commit 992ea29

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bin/v-backup-user

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,15 @@ if [ "$USER" != '*' ]; then
466466
fi
467467
fargs=()
468468
for xpath in $(echo "$USER" |tr ',' '\n'); do
469-
fargs+=(-not)
470-
fargs+=(-path)
471-
fargs+=("./$xpath*")
472-
echo "$(date "+%F %T") excluding directory $xpath" |\
469+
if [ -d "$xpath" ]; then
470+
fargs+=(--exclude=$xpath/*)
471+
echo "$(date "+%F %T") excluding directory $xpath" |\
473472
tee -a $BACKUP/$user.log
473+
else
474+
echo "$(date "+%F %T") excluding file $xpath" |\
475+
tee -a $BACKUP/$user.log
476+
fargs+=(--exclude=$xpath)
477+
fi
474478
done
475479

476480
IFS=$'\n'
@@ -487,7 +491,7 @@ if [ "$USER" != '*' ]; then
487491
check_backup_conditions
488492

489493
# Backup files and dirs
490-
tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
494+
tar --anchored -cpf- ${fargs[@]} $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
491495
fi
492496
done
493497
set +f

0 commit comments

Comments
 (0)