6 Commits

3 changed files with 57 additions and 7 deletions

38
.gitignore vendored
View File

@@ -16,7 +16,39 @@
# exclude the certificates config folder # exclude the certificates config folder
/config/traefik/dynamic/* /config/traefik/dynamic/*
!/config/traefik/dynamic/.gitkeep !/config/traefik/dynamic/.gitkeep
# Python cache/bytecode
__pycache__/
*.py[cod]
.DS_Store .DS_Store
secrets secrets/
Persistent Backup
backups/* # Backup files and directories
/backups/
*.tar.gz
*.sql.gz
*.sql
Persistent Backup/
# Python cache
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
# Database files
*.db
*.sqlite
*.sqlite3
# Log files
*.log
# Editor settings
.vscode/
*.swp
*.swo
*~
# Windows
Thumbs.db

View File

@@ -13,5 +13,5 @@
"views/mrp_lot_mix_views.xml", "views/mrp_lot_mix_views.xml",
], ],
"installable": True, "installable": True,
"application": False, "application": True,
} }

View File

@@ -150,8 +150,11 @@ cleanup_old_backups() {
done done
fi fi
} }
# Prepare dated backup directory # Prepare dated backup directory using a stable run timestamp.
DATED_DIR="$BACKUP_BASE/$(date_formatted)" # This prevents later steps from missing files if the minute changes while
# long archive operations are running.
RUN_STAMP="$(date_formatted)"
DATED_DIR="$BACKUP_BASE/$RUN_STAMP"
mkdir -p "$DATED_DIR" mkdir -p "$DATED_DIR"
wait_for_database_backups || exit 1 wait_for_database_backups || exit 1
@@ -188,7 +191,22 @@ log "Moving files from database dump to dated directory..."
#log "Files to move:" #log "Files to move:"
ls -1 "$BACKUP_BASE/databases"/* 2>/dev/null || true ls -1 "$BACKUP_BASE/databases"/* 2>/dev/null || true
log "Moving database dumps to dated directory..." log "Moving database dumps to dated directory..."
mv "$BACKUP_BASE/databases"/*_$(date_formatted)*.sql.gz "$DATED_DIR"/ 2>/dev/null || true
dump_moved=0
for dump_file in "$BACKUP_BASE/databases"/*_"$RUN_STAMP"*.sql.gz; do
[ -e "$dump_file" ] || break
if mv "$dump_file" "$DATED_DIR"/; then
dump_moved=$((dump_moved + 1))
else
err "Failed to move database dump $dump_file"
fi
done
if [ "$dump_moved" -eq 0 ]; then
log "No database dumps matched run timestamp $RUN_STAMP"
else
log "Moved $dump_moved database dump(s) to $DATED_DIR"
fi
cleanup_old_backups cleanup_old_backups