mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-28 01:48:14 +03:00
Minor echo changes and additions (#9)
- Remove unnecessary `echo`es. - Remove `LOGFILE` environment variable. - Minor documentation and `echo` changes and additions.
This commit is contained in:
parent
48b391d082
commit
f9531d4a50
@ -13,7 +13,6 @@ ENV CRON_TIME "0 */12 * * *"
|
|||||||
ENV UID 100
|
ENV UID 100
|
||||||
ENV GID 100
|
ENV GID 100
|
||||||
ENV CRONFILE /etc/crontabs/root
|
ENV CRONFILE /etc/crontabs/root
|
||||||
ENV LOGFILE /app/log/backup.log
|
|
||||||
ENV DELETE_AFTER 0
|
ENV DELETE_AFTER 0
|
||||||
|
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
@ -55,7 +55,6 @@ services:
|
|||||||
| Environment Variable | Info |
|
| Environment Variable | Info |
|
||||||
| -------------------- | -------------------------------------------------------------------------------------------- |
|
| -------------------- | -------------------------------------------------------------------------------------------- |
|
||||||
| TZ ¹ | Timezone inside the container. Can mount `/etc/localtime` instead as well _(recommended)_. |
|
| TZ ¹ | Timezone inside the container. Can mount `/etc/localtime` instead as well _(recommended)_. |
|
||||||
| LOGFILE | Log file path relative to inside the container. |
|
|
||||||
| CRONFILE | Cron file path relative to inside the container. |
|
| CRONFILE | Cron file path relative to inside the container. |
|
||||||
|
|
||||||
¹ See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for more information
|
¹ See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for more information
|
||||||
|
@ -12,6 +12,5 @@ BACKUP_ATTACHMENTS=attachments # directory
|
|||||||
BACKUP_SENDS=sends # directory
|
BACKUP_SENDS=sends # directory
|
||||||
|
|
||||||
# Create an archive of the files and directories.
|
# Create an archive of the files and directories.
|
||||||
echo "[INFO] Starting backup at $(date +"%F %r")..."
|
|
||||||
cd /data && tar -Jcf $BACKUP_LOCATION $BACKUP_DB $BACKUP_RSA $BACKUP_CONFIG $BACKUP_ATTACHMENTS $BACKUP_SENDS 2>/dev/null && cd /
|
cd /data && tar -Jcf $BACKUP_LOCATION $BACKUP_DB $BACKUP_RSA $BACKUP_CONFIG $BACKUP_ATTACHMENTS $BACKUP_SENDS 2>/dev/null && cd /
|
||||||
echo "[INFO] Backup completed at $(date +"%F %r")."
|
echo "[INFO] Created a new backup on $(date +"%F %r")."
|
||||||
|
@ -1,33 +1,31 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
|
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
|
||||||
|
LOGS_FILE="/app/log/backup.log"
|
||||||
echo "Running $(basename "$0") as $(id)"
|
|
||||||
|
|
||||||
# Run backup script once ($1 = First argument passed).
|
# Run backup script once ($1 = First argument passed).
|
||||||
if [ "$1" = "manual" ]; then
|
if [ "$1" = "manual" ]; then
|
||||||
|
echo "[INFO] Running one-time, started at $(date +"%F %r")."
|
||||||
$BACKUP_CMD
|
$BACKUP_CMD
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize cron
|
# Create cron jobs.
|
||||||
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
|
||||||
echo "Initalizing..."
|
echo "$CRON_TIME $BACKUP_CMD >> $LOGS_FILE 2>&1" | crontab -
|
||||||
echo "Writing backup command \"$BACKUP_CMD\" to cron."
|
# Delete after x days job here.
|
||||||
echo "$CRON_TIME $BACKUP_CMD >> $LOGFILE 2>&1" | crontab -
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start crond if it's not running
|
# Start crond if it's not running.
|
||||||
pgrep crond > /dev/null 2>&1
|
pgrep crond > /dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
/usr/sbin/crond -L /app/log/cron.log
|
/usr/sbin/crond -L /app/log/cron.log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart script as user "app:app"
|
# Restart script as user "app:app".
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
echo "Restarting $(basename "$0") as app:app"
|
|
||||||
exec su-exec app:app "$0" "$@"
|
exec su-exec app:app "$0" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[INFO] Container started at $(date +"%F %r")" > "$LOGFILE"
|
echo "[INFO] Running automatically (${CRON_TIME}), started at $(date +"%F %r")." > "$LOGS_FILE"
|
||||||
tail -F "$LOGFILE" /app/log/cron.log
|
tail -F "$LOGS_FILE" # Keeps terminal open and writes logs.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user