backup-job.sh 759 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env sh
  2. execute_backup_job() {
  3. BACKUP_ARG_PATH="${1:-}"
  4. BACKUP_ARG_CONFIG="${BACKUP_ARG_CONFIG:-}"
  5. BACKUP_ARG_EXCLUDE_REPOS="${BACKUP_ARG_EXCLUDE_REPOS:-}"
  6. cd "/app/gogs" || exit 1
  7. BACKUP_ARGS="--target=${BACKUP_ARG_PATH}"
  8. if [ -n "${BACKUP_ARG_CONFIG}" ]; then
  9. BACKUP_ARGS="${BACKUP_ARGS} --config=${BACKUP_ARG_CONFIG}"
  10. fi
  11. if [ -n "${BACKUP_ARG_EXCLUDE_REPOS}" ]; then
  12. BACKUP_ARGS="${BACKUP_ARGS} --exclude-repos=${BACKUP_ARG_EXCLUDE_REPOS}"
  13. fi
  14. ./gogs backup "${BACKUP_ARGS}" || echo "Error: Backup job returned non-successful code." && exit 1
  15. }
  16. main() {
  17. BACKUP_PATH="${1:-}"
  18. if [ -z "${BACKUP_PATH}" ]; then
  19. echo "Required argument missing BACKUP_PATH" 1>&2
  20. exit 1
  21. fi
  22. execute_backup_job "${BACKUP_PATH}"
  23. }
  24. main "$@"