run.sh 631 B

123456789101112131415161718192021
  1. #!/bin/sh -xe
  2. # Init restic repository if neccessary
  3. restic snapshots &>/dev/null || restic init
  4. # Monitoring: Set metric to started
  5. /root/restic/push-metric.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. # Monitoring: Set metric based on the result code of the backup job
  10. case $? in
  11. 0) /root/restic/push-metric.sh stop ;;
  12. 3) /root/restic/push-metric.sh incomplete ;;
  13. 1|*) /root/restic/push-metric.sh fail ;;
  14. esac
  15. # Cleanup old backups
  16. restic forget $RESTIC_FORGET_ARGS