Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mariadb-backup-runner #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions mariadb-backup-runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# After Pacific (PT) end-of-day:
# 5:38pm (winter) / 6:38pm (summer) PT
my_pt_utc_eod="01"

# Before Eastern (ET) start-of-day:
# 3:38am (winter) / 4:38am (summer) ET
my_et_utc_sod="08"

my_minute="38"

my_first="non-zero"

echo "Backup task started."
echo "Will run at '$my_pt_utc_eod:$my_minute UTC' and '$my_et_utc_sod:$my_minute UTC'."
while true; do
my_hours="$(date -u '+%H')"
my_minutes="$(date -u '+%M')"
echo "Current time is '$my_hours:$my_minutes UTC'"

if test "$my_hours" = "$my_pt_utc_eod" ||
test "$my_hours" = "$my_et_utc_sod" ||
test -n "${my_first}"; then
if test "$my_minutes" = "38" ||
test -n "${my_first}"; then

echo ""
echo "Backup tasks starting"
./mariadb-backup \
/mnt/storage/mariadb-staging.env \
/mnt/storage/mariadb-staging.d/
echo "Backup tasks complete"
echo ""

if test -z "${my_first}"; then
sleep "$((6 * 60 * 60))"
fi
my_first=""
fi
fi

# account for accumulated sub-second skews by sleep
sleep 59
done
9 changes: 9 additions & 0 deletions mariadb-backup-service-add
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
set -u

# curl https://webi.sh/serviceman | sh

# may need --path "${PATH}" if other bins are needed in the PATH
sudo env PATH="$PATH" \
serviceman add --system --username "$(id -u -n)" --name 'mariadb-backup' ./mariadb-backup-runner