sometimes do hot backups

This commit is contained in:
2026-07-25 21:31:15 +01:00
parent 7d4f8ca9c5
commit f6cfb706da
2 changed files with 18 additions and 6 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ always remember to `docker compose stop` before doing any of this!
- to back up automatically, run `sudo EDITOR=micro crontab -e` and add the following: - to back up automatically, run `sudo EDITOR=micro crontab -e` and add the following:
``` ```
TZ=UTC TZ=UTC
0 6 * * * /home/admin/atom.town/scripts/volume-backup.sh 0 6 * * * /home/admin/atom.town/scripts/volume-backup.sh cold
0 0,12,18 * * * /home/admin/atom.town/scripts/volume-backup.sh hot
``` ```
**restoring** **restoring**
+13 -2
View File
@@ -8,19 +8,30 @@ function log() {
echo "[$(date -Iseconds)] $*" | tee -a "$LOG_FILE" echo "[$(date -Iseconds)] $*" | tee -a "$LOG_FILE"
} }
MODE="${1:-cold}"
if [[ "$MODE" != "cold" && "$MODE" != "hot" ]]; then
log "usage: $0 [cold|hot]" >&2
exit 1
fi
function cleanup() { function cleanup() {
log "cleanup: starting docker services" if [[ "$MODE" == "cold" ]]; then
log "starting docker services"
docker compose start || true docker compose start || true
fi
log "└───── backup finished ─────┘" log "└───── backup finished ─────┘"
} }
trap cleanup EXIT trap cleanup EXIT
log "┌────── backup started ─────┐" log "┌────── backup started ─────┐"
log "mode: $MODE"
cd "$WORKING_DIR" cd "$WORKING_DIR"
if [[ "$MODE" == "cold" ]]; then
log "stopping docker services" log "stopping docker services"
docker compose stop docker compose stop
fi
log "running backup" log "running backup"
/usr/local/bin/vykar backup /usr/local/bin/vykar backup 2>&1 | tee -a "$LOG_FILE"