#!/bin/sh set -eu temporary=$(mktemp) app_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) trap 'rm -f -- "$temporary"' EXIT HUP INT TERM crontab -l 2>/dev/null | grep -v 'postgres-backup.sh' > "$temporary" || true printf '%s\n' "30 3 * * 0 flock -n /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh >/dev/null 2>&1" >> "$temporary" crontab "$temporary"