Compare commits

...

7 Commits

Author SHA1 Message Date
458ce5534b interruption handling
All checks were successful
Container Publish / on-success-skip (push) Has been skipped
Container Publish / build-image (amd64) (push) Successful in 41s
Container Publish / build-image (arm64) (push) Successful in 47s
Container Publish / update docker manifest (push) Successful in 11s
Vulnerability Scan / Daily Vulnerability Scan (arm64) (push) Successful in 8s
Vulnerability Scan / Daily Vulnerability Scan (amd64) (push) Successful in 28s
2025-12-14 22:01:29 +01:00
1ebd6512d8 better healthcheck 2025-12-14 22:00:57 +01:00
5b23ca2243 healthcheck startup 2025-12-14 21:48:08 +01:00
e551d60679 temp file cleanup 2025-12-14 21:45:07 +01:00
18cef1c84e cron log level 2025-12-14 21:44:49 +01:00
9b56614763 shellcheck 2025-12-14 21:34:06 +01:00
6caf3686d4 added gitignore 2025-12-14 21:32:55 +01:00
4 changed files with 17 additions and 10 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
docker-compose.yaml
config/

View File

@@ -6,7 +6,7 @@ RUN \
COPY rootfs / COPY rootfs /
HEALTHCHECK --interval=2m --timeout=3s \ HEALTHCHECK --interval=1m --timeout=3s --start-period=20s --retries=1 \
CMD /app/healthcheck.sh || exit 1 CMD /app/healthcheck.sh || exit 1
ENTRYPOINT [ "/sbin/tini", "/app/entrypoint.sh" ] ENTRYPOINT [ "/sbin/tini", "/app/entrypoint.sh" ]

View File

@@ -1,10 +1,7 @@
#!/bin/sh #!/bin/sh
set -o pipefail
STATUS_FILE=/last_backup_status.txt STATUS_FILE=/last_backup_status.txt
MARIADB_HOST=${MARIADB_HOST:-db} MARIADB_HOST=${MARIADB_HOST:-db}
MARIADB_USER=${MARIADB_USER:-root} MARIADB_USER=${MARIADB_USER:-root}
MARIADB_PORT=${MARIADB_PORT:-3306} MARIADB_PORT=${MARIADB_PORT:-3306}
@@ -22,10 +19,17 @@ BACKUP_FILE="${TMPDIR}/${DEST_FILENAME}"
trap cleanup EXIT trap cleanup EXIT
cleanup() { cleanup() {
# rm -rf "${TMPDIR}" rm -rf "${TMPDIR}"
echo "Removed temporary file" echo "Removed temporary file"
} }
trap interrupt INT
interrupt() {
echo "Backup interrupted"
echo "interrupted" > "${STATUS_FILE}"
exit 1
}
if [ ! -f "${RCLONE_CONFIG_FILE}" ]; then if [ ! -f "${RCLONE_CONFIG_FILE}" ]; then
echo "Rclone config file not found" echo "Rclone config file not found"
exit 1 exit 1
@@ -51,7 +55,7 @@ copy_failed() {
exit 1 exit 1
} }
COMPRESSOR=cat COMPRESSOR="cat"
if [ "${COMPRESSION}" = "gzip" ]; then if [ "${COMPRESSION}" = "gzip" ]; then
COMPRESSOR="gzip" COMPRESSOR="gzip"
BACKUP_FILE="${BACKUP_FILE}.gz" BACKUP_FILE="${BACKUP_FILE}.gz"
@@ -85,9 +89,9 @@ mariadb-dump \
--quick \ --quick \
--triggers \ --triggers \
--tz-utc -v \ --tz-utc -v \
--host=${MARIADB_HOST} \ --host="${MARIADB_HOST}" \
--port=${MARIADB_PORT} \ --port="${MARIADB_PORT}" \
--user=${MARIADB_USER} \ --user="${MARIADB_USER}" \
--password="${MARIADB_PASSWORD}" \ --password="${MARIADB_PASSWORD}" \
--databases "${MARIADB_DATABASE}" | "${COMPRESSOR}" > "${BACKUP_FILE}" || dump_failed --databases "${MARIADB_DATABASE}" | "${COMPRESSOR}" > "${BACKUP_FILE}" || dump_failed

View File

@@ -4,4 +4,5 @@ CRONTAB=${CRONTAB:-"0 12 * * *"}
echo "${CRONTAB} /app/backup.sh" > /etc/crontabs/root echo "${CRONTAB} /app/backup.sh" > /etc/crontabs/root
crond -f echo "Starting cron"
crond -f -d 7