restic-scripts/backup.sh

27 lines
710 B
Bash
Raw Normal View History

2023-01-17 13:21:39 +01:00
#!/bin/bash
source env.sh
echo "Backup $NAME at $DATE"
2023-01-17 13:30:11 +01:00
BACKUP_CMD=restic backup $BACKUP_DIR
if [[ $BACKUP_PARAMS ]]; then
BACKUP_CMD=$BACKUP_CMD $BACKUP_PARAMS
fi
if [[ $BACKUP_EXCLUDE_FILE ]]; then
BACKUP_CMD=$BACKUP_CMD --exclude-file $BACKUP_EXCLUDE_FILE
fi
2023-01-17 13:21:39 +01:00
running=$(pgrep -f "$BACKUP_CMD")
if [[ $running ]]; then
echo "Backup alreadying running : $running. Exiting..."
curl https://hc-ping.com/$HEALTHCHECK_UUID/fail
exit
fi
echo "Not currently running. Continuing..."
curl https://hc-ping.com/$HEALTH_UUID/start
$PRE_RUN_SCRIPTS
$BACKUP_CMD
if [[ $? == 0 ]]; then
$POST_RUN_SCRIPTS
2023-01-17 13:21:39 +01:00
curl https://hc-ping.com/$HEALTH_UUID
else
curl https://hc-ping.com/$HEALTH_UUID/fail
fi