Compare commits

...

7 Commits

Author SHA1 Message Date
Sergey Paramoshkin 9b32782de2 fix sleep
build (backupdb) TeamCity build finished Details
2025-09-25 10:43:54 +03:00
Sergey Paramoshkin b116401130 add sleep
build (backupdb) TeamCity build finished Details
2025-09-25 10:35:19 +03:00
Sergey Paramoshkin ee2b686c1b add routines
build (backupdb) TeamCity build finished Details
2025-09-23 10:44:35 +03:00
Sergey Paramoshkin 8f0e46a4ea fix
build (backupdb) TeamCity build finished Details
2025-09-22 23:52:42 +03:00
Sergey Paramoshkin 4dec38b4e4 revert
build (backupdb) TeamCity build finished Details
2025-09-22 23:50:00 +03:00
Sergey Paramoshkin 0db9c1c0cb fix
build (backupdb) TeamCity build finished Details
2025-09-22 23:45:38 +03:00
Sergey Paramoshkin 22ad368271 migrate to mariadb
build (backupdb) TeamCity build failed Details
2025-09-22 23:42:44 +03:00
2 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,4 @@
FROM mariadb:10.6.23 FROM mariadb:10.3.25
# Install rclone (ignore apt update errors from old repos) # Install rclone (ignore apt update errors from old repos)
RUN apt-get update || true && \ RUN apt-get update || true && \

View File

@ -11,7 +11,7 @@ KEEP_BACKUPS="${KEEP_BACKUPS:-7}"
S3_BUCKET="${S3_BUCKET:-selectel:backup_db}" S3_BUCKET="${S3_BUCKET:-selectel:backup_db}"
S3_PATH="${S3_PATH:-dot}" S3_PATH="${S3_PATH:-dot}"
ENVIRONMENT="${ENVIRONMENT:-prod}" ENVIRONMENT="${ENVIRONMENT:-prod}"
SLEEP=${SLEEP:-43200}
while true; do while true; do
echo "[$(date)] Starting database backup process..." echo "[$(date)] Starting database backup process..."
@ -20,7 +20,7 @@ while true; do
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "[$(date)] ERROR: Failed to get database list!" echo "[$(date)] ERROR: Failed to get database list!"
sleep 43200 sleep ${SLEEP}
continue continue
fi fi
@ -32,7 +32,7 @@ while true; do
echo "[$(date)] Backing up database: ${database}..." echo "[$(date)] Backing up database: ${database}..."
# Create backup with compression # Create backup with compression (MariaDB compatible)
mysqldump -h "${DB_HOST}" \ mysqldump -h "${DB_HOST}" \
-u"${DB_USER}" \ -u"${DB_USER}" \
-p"${DB_PASSWORD}" \ -p"${DB_PASSWORD}" \
@ -42,6 +42,11 @@ while true; do
--extended-insert \ --extended-insert \
--quick \ --quick \
--lock-tables=false \ --lock-tables=false \
--skip-add-locks \
--skip-comments \
--routines \
--triggers \
--events \
"${database}" | gzip -c > "${BACKUP_FILE}" "${database}" | gzip -c > "${BACKUP_FILE}"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@ -80,7 +85,7 @@ while true; do
echo "[$(date)] Current local backups:" echo "[$(date)] Current local backups:"
ls -lah ${BACKUP_DIR}/*.sql.gz 2>/dev/null || echo "No backups found" ls -lah ${BACKUP_DIR}/*.sql.gz 2>/dev/null || echo "No backups found"
echo "[$(date)] Next backup will run in 12 hours..." echo "[$(date)] Next backup will run in $((${SLEEP} / 60 / 60 )) hours..."
echo "=========================================" echo "========================================="
# Sleep for 12 hours (43200 seconds) # Sleep for 12 hours (43200 seconds)