fix: install.sh backup preserves database owner using stat
- Uses stat to get original owner:group before backup - chown restores backup file to original owner - Prevents database becoming readonly after update
This commit is contained in:
parent
91534ed8bd
commit
e547eee57f
1 changed files with 2 additions and 2 deletions
|
|
@ -79,8 +79,8 @@ if [ "${1:-}" = "-update" ]; then
|
|||
sudo_if mkdir -p "$BACKUP_DIR"
|
||||
BACKUP_FILE="$BACKUP_DIR/expenses-$(date +%Y%m%d-%H%M%S).db"
|
||||
sudo_if cp "$INSTALL_DIR/expenses.db" "$BACKUP_FILE"
|
||||
# Restore ownership so the app user can still write to the database.
|
||||
sudo_if chown --reference="$INSTALL_DIR/expenses.db" "$BACKUP_FILE" 2>/dev/null || true
|
||||
# Restore file ownership so the app user can still write.
|
||||
sudo_if chown $(stat -c "%U:%G" "$INSTALL_DIR/expenses.db") "$BACKUP_FILE" 2>/dev/null || true
|
||||
info "Database backed up to $BACKUP_FILE"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue