forked from djmaze/resticker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint
More file actions
executable file
·47 lines (45 loc) · 1.55 KB
/
entrypoint
File metadata and controls
executable file
·47 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -euo pipefail
echo "Checking configured repository '${RESTIC_REPOSITORY}' ..."
if restic cat config > /dev/null; then
echo "Repository found."
else
echo "Could not access the configured repository. Trying to initialize (in case it has not been initialized yet) ..."
if restic init; then
echo "Repository successfully initialized."
else
if [ "${SKIP_INIT_CHECK:-}" == "true" ]; then
echo "Initialization failed. Ignoring errors because SKIP_INIT_CHECK is set in your configuration."
else
echo "Initialization failed. Please see error messages above and check your configuration. Exiting."
exit 1
fi
fi
fi
echo -e "\n"
if [[ $# -gt 0 ]]; then
exec restic "$@"
else
if [[ -n "${BACKUP_CRON:-}" ]] && [[ -n "${PRUNE_CRON:-}" ]]; then
>&2 echo "Environment variables BACKUP_CRON and PRUNE_CRON are mutually exclusive. Please fix your configuration. Exiting."
exit 1
fi
if [[ -n "${BACKUP_CRON:-}" ]]; then
if [ "${RUN_ON_STARTUP:-}" == "true" ]; then
echo "Executing backup on startup ..."
/usr/local/bin/backup
fi
echo "Scheduling backup job according to cron expression."
exec go-cron "$BACKUP_CRON" /usr/local/bin/backup
fi
if [[ -n "${PRUNE_CRON:-}" ]]; then
if [ "${RUN_ON_STARTUP:-}" == "true" ]; then
echo "Executing prune job on startup ..."
/usr/local/bin/prune
fi
echo "Scheduling prune job according to cron expression."
exec go-cron "$PRUNE_CRON" /usr/local/bin/prune
fi
>&2 echo "No valid operating mode configured! Exiting."
exit 1
fi