36 lines
940 B
Bash
36 lines
940 B
Bash
#!/bin/sh
|
|
|
|
# Install the borg package
|
|
os=$(cat "${__global:?}/explorer/os")
|
|
case "$os" in
|
|
alpine|ubuntu|debian)
|
|
__package borgbackup
|
|
;;
|
|
*)
|
|
echo "This type does not support $os. Exiting." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Get the repository location.
|
|
repository=$(cat "${__object:?}/parameter/repository")
|
|
|
|
# Use optionally specified excludes, or default ones for GNU/Linux.
|
|
if [ -f "${__object:?}/parameter/exclude" ]; then
|
|
excludes=$(cat "$__object/parameter/exclude")
|
|
else
|
|
excludes="/sys /proc /dev /run"
|
|
fi
|
|
|
|
# Build command
|
|
unknown_repo_warning_fragment="BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes"
|
|
|
|
for path in $excludes; do
|
|
exclude_fragment="$exclude_fragment --exclude $path"
|
|
done
|
|
|
|
borg_command="sh -c \"$unknown_repo_warning_fragment borg create $exclude_fragment --stats $repository::daily-\\\$(date -I) /\""
|
|
|
|
# Setup cronjob.
|
|
require="__package/borgbackup" __cron daily-backup --user root --command "$borg_command" --hour 2
|