fix: update mode backs up database before making changes
- Creates timestamped backup at /opt/receiptnext/backups/expenses-YYYYMMDD-HHMMSS.db - rsync only targets templates/ and static/ — database is never touched
This commit is contained in:
parent
c386b150c4
commit
5aca6c06a5
1 changed files with 9 additions and 0 deletions
|
|
@ -68,6 +68,15 @@ if [ "${1:-}" = "-update" ]; then
|
|||
cd "$INSTALL_DIR"
|
||||
fi
|
||||
|
||||
# Backup the database before making any changes.
|
||||
if [ -f "$INSTALL_DIR/expenses.db" ]; then
|
||||
BACKUP_DIR="$INSTALL_DIR/backups"
|
||||
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"
|
||||
info "Database backed up to $BACKUP_FILE"
|
||||
fi
|
||||
|
||||
# Copy updated templates, static assets, and config files.
|
||||
info "Updating templates and static assets..."
|
||||
sudo_if rsync -a --delete templates/ "$INSTALL_DIR/templates/" 2>/dev/null || true
|
||||
|
|
|
|||
Loading…
Reference in a new issue