From cdf74efda0467fb31925cd4b7a3e1b461e54483b Mon Sep 17 00:00:00 2001 From: yuuki <> Date: Wed, 11 Sep 2024 11:43:10 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E5=88=9D=E3=81=AE=E3=82=B3=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taiko-web-db-cron.sh | 17 +++++++++++++++++ taiko-web-db.service | 12 ++++++++++++ taiko-web-db.timer | 8 ++++++++ 3 files changed, 37 insertions(+) create mode 100644 taiko-web-db-cron.sh create mode 100644 taiko-web-db.service create mode 100644 taiko-web-db.timer diff --git a/taiko-web-db-cron.sh b/taiko-web-db-cron.sh new file mode 100644 index 0000000..4a65f39 --- /dev/null +++ b/taiko-web-db-cron.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eu + +test "$(docker container inspect -f '{{.State.Status}}' taiko-mongo)" = "running" + +cd ~/taiko-web-db + +git reset --hard HEAD + +docker exec -i taiko-mongo mongoexport --db taiko --collection users --out /dev/stdout | sort -n > users.json +docker exec -i taiko-mongo mongoexport --db taiko --collection songs --out /dev/stdout | sort -n > songs.json +docker exec -i taiko-mongo mongoexport --db taiko --collection scores --out /dev/stdout | sort -n > scores.json + +git add *.json +git commit --author="BOT " -m "$(git diff --name-only --cached | paste -s -d ' ') が更新されました" +git push origin main diff --git a/taiko-web-db.service b/taiko-web-db.service new file mode 100644 index 0000000..b147127 --- /dev/null +++ b/taiko-web-db.service @@ -0,0 +1,12 @@ +[Unit] +Description=My Taiko Web's DB Backup Service + +[Service] +User=root +Group=root +WorkingDirectory=/root +ExecStart=bash taiko-web-db-cron.sh +Type=simple + +[Install] +WantedBy=multi-user.target diff --git a/taiko-web-db.timer b/taiko-web-db.timer new file mode 100644 index 0000000..04c7e95 --- /dev/null +++ b/taiko-web-db.timer @@ -0,0 +1,8 @@ +[Unit] +Description=My Taiko Web's DB Backup Cron Service + +[Timer] +OnCalendar=*:0/1 + +[Install] +WantedBy=timers.target