run.sh 667 B

123456789101112131415161718192021
  1. #!/bin/sh -xe
  2. # Init restic repository if neccessary
  3. restic snapshots &>/dev/null || restic init
  4. # Notify prometheus on backup start if $PROM_GW_URL is set
  5. /root/restic/notify-prom-status.sh start
  6. # Run backup job, using parameters from AWS_ACCESS_KEY_ID,
  7. # AWS_SECRET_ACCESS_KEY, RESTIC_PASSWORD, RESTIC_REPOSITORY
  8. restic backup $RESTIC_BACKUP_ARGS $RESTIC_BACKUP_FOLDERS
  9. case $? in
  10. 0) /root/restic/notify-prom-status.sh stop
  11. /root/restic/notify-prom-stats.sh ;;
  12. 3) /root/restic/notify-prom-status.sh incomplete ;;
  13. 1|*) /root/restic/notify-prom-status.sh fail ;;
  14. esac
  15. # Cleanup old backups
  16. restic forget $RESTIC_FORGET_ARGS