Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ At least one of the `RESTIC_PASSWORD*` variables need to be defined, along with

Use the `RESTIC_ADDITIONAL_TAGS` variable to define a space separated list of additional restic tags. The backup will always be tagged with the value of `BACKUP_NAME`. e.g.: `RESTIC_ADDITIONAL_TAGS=mc_backups foo bar` will tag your backup with `foo`, `bar`, `mc_backups` and the value of `BACKUP_NAME`.

By default, the hostname, typically the container/pod's name, will be used as the Restic backup's hostname. That can be overridden by setting `RESTIC_HOSTNAME`
By default, the hostname, typically the container/pod's name, will be used as the Restic backup's hostname. That can be overridden by setting `RESTIC_HOST`. The legacy `RESTIC_HOSTNAME` variable is also supported when `RESTIC_HOST` is not set.

If you want to limit the restic backup upload speed, you can set the `RESTIC_LIMIT_UPLOAD` variable to a value in KiB/s. For example, `RESTIC_LIMIT_UPLOAD=1024` will limit the upload speed to approximately 1 MiB/s. By default, there is no limit.

Expand Down
8 changes: 4 additions & 4 deletions scripts/opt/backup-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fi
: "${EXCLUDES_FILE:=}" # Path to file containing list of glob(3) patterns
: "${LINK_LATEST:=false}"
: "${RESTIC_ADDITIONAL_TAGS=mc_backups}" # Space separated list of restic tags
: "${RESTIC_HOSTNAME:=$(hostname)}"
: "${RESTIC_HOST:=${RESTIC_HOSTNAME:-$(hostname)}}"
: "${RESTIC_VERBOSE:=false}"
: "${RESTIC_LIMIT_UPLOAD:=0}"
: "${RESTIC_CAT_CONFIG_TIMEOUT:=10s}"
Expand All @@ -69,6 +69,7 @@ export XDG_CONFIG_HOME
export SRC_DIR
export DEST_DIR
export BACKUP_NAME
export RESTIC_HOST

resolve_backup_name() {
if ! isTrue "$NAME_WITH_VERSION"; then
Expand Down Expand Up @@ -459,7 +460,7 @@ restic() {

_delete_old_backups() {
# shellcheck disable=SC2086
command restic --retry-lock "${RESTIC_RETRY_LOCK}" forget --host "${RESTIC_HOSTNAME}" --tag "${restic_tags_filter}" ${PRUNE_RESTIC_RETENTION} "${@}"
command restic --retry-lock "${RESTIC_RETRY_LOCK}" forget --tag "${restic_tags_filter}" ${PRUNE_RESTIC_RETENTION} "${@}"
}

_unlock() {
Expand Down Expand Up @@ -553,10 +554,9 @@ restic() {
exit 1
fi

log INFO "Backing up content in ${SRC_DIR} as host ${RESTIC_HOSTNAME}"
log INFO "Backing up content in ${SRC_DIR} as host ${RESTIC_HOST}"
args=(
--retry-lock "${RESTIC_RETRY_LOCK}"
--host "${RESTIC_HOSTNAME}"
--limit-upload "${RESTIC_LIMIT_UPLOAD}"
)
if isDebug || isTrue "$RESTIC_VERBOSE"; then
Expand Down
4 changes: 4 additions & 0 deletions tests/test.simple.restic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ trap 'sudo rm -rf "${TMP_DIR}"' EXIT
: "${EXCLUDES:='*.jar,exclude_dir'}"
: "${RCON_PATH:=/usr/bin/rcon-cli}"
: "${RESTIC_PASSWORD:=1234}"
: "${RESTIC_HOSTNAME:=legacy-restic-host}"

export LOCAL_SRC_DIR="${TMP_DIR}/${SRC_DIR}"
export LOCAL_DEST_DIR="${TMP_DIR}/${DEST_DIR}"
Expand All @@ -33,6 +34,7 @@ export INITIAL_DELAY
export EXCLUDES
export RCON_PATH
export RESTIC_PASSWORD
export RESTIC_HOSTNAME

timeout --kill-after=20 50 docker run --rm \
--env SRC_DIR \
Expand All @@ -42,6 +44,7 @@ timeout --kill-after=20 50 docker run --rm \
--env PRUNE_BACKUPS_DAYS \
--env RESTIC_REPOSITORY \
--env RESTIC_PASSWORD \
--env RESTIC_HOSTNAME \
--env DEBUG \
--env BACKUP_METHOD=restic \
--mount "type=bind,src=${LOCAL_SRC_DIR},dst=${SRC_DIR}" \
Expand All @@ -59,5 +62,6 @@ restic() {
localhost:5000/itzg/mc-backup:latest "${@}"
}
restic ls latest
test "$(restic snapshots --host "${RESTIC_HOSTNAME}" --json | jq length)" -eq 1
! restic ls latest 2>/dev/null | grep -q "exclude_"
[ 4 -eq "$(restic ls latest 2>/dev/null | grep -c "backup_me")" ]