Revert "Allow extra args for non-backup commands (#115)"

This reverts commit 2406f078ef.

As of #120
This commit is contained in:
Erik Westrup
2023-09-25 18:33:33 +02:00
parent 3f05091edb
commit 3cdf1503ae
3 changed files with 5 additions and 22 deletions

View File

@@ -6,11 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Support for extra args for all restic commands with `RESTIC_EXTRA_ARGS`. [115](https://github.com/erikw/restic-automatic-backup-scheduler/pull/115/)
- Debug scripts by setting `TRACE=1`.
### Changed
- Warn on certain unset envvars instead of error-exit.
- Allow escaped spaces in EXTRA_ARGS.
## [7.4.0] - 2023-03-08
### Added

View File

@@ -64,12 +64,7 @@ IFS=':' read -ra backup_paths <<< "$RESTIC_BACKUP_PATHS"
# Convert to array, an preserve spaces. See #111
extra_args=( )
while IFS= read -r -d ''; do
extra_args+=( "$REPLY" )
done < <(xargs printf '%s\0' <<<"$RESTIC_EXTRA_ARGS")
backup_extra_args=( )
while IFS= read -r -d ''; do
backup_extra_args+=( "$REPLY" )
extra_args+=( "$REPLY" )
done < <(xargs printf '%s\0' <<<"$RESTIC_BACKUP_EXTRA_ARGS")
B2_ARG=
@@ -101,8 +96,7 @@ test "$OSTYPE" = msys || FS_ARG=--one-file-system
# Reference: https://unix.stackexchange.com/questions/146756/forward-sigterm-to-child-in-bash
# Remove locks from other stale processes to keep the automated backup running.
restic unlock \
"${extra_args[@]}" &
restic unlock &
wait $!
# Do the backup!
@@ -116,7 +110,6 @@ restic backup \
"${B2_ARG[@]}" \
"${exclusion_args[@]}" \
"${extra_args[@]}" \
"${backup_extra_args[@]}" \
"${backup_paths[@]}" &
wait $!
@@ -127,7 +120,6 @@ restic forget \
--verbose="$RESTIC_VERBOSITY_LEVEL" \
--tag "$RESTIC_BACKUP_TAG" \
"${B2_ARG[@]}" \
"${extra_args[@]}" \
--prune \
--group-by "paths,tags" \
--keep-hourly "$RESTIC_RETENTION_HOURS" \
@@ -149,13 +141,13 @@ if [ "$RESTIC_NOTIFY_BACKUP_STATS" = true ]; then
if [ -w "$RESTIC_BACKUP_NOTIFICATION_FILE" ]; then
echo 'Notifications are enabled: Silently computing backup summary stats...'
snapshot_size=$(restic stats latest --tag "$RESTIC_BACKUP_TAG" "${extra_args[@]}" | grep -i 'total size:' | cut -d ':' -f2 | xargs) # xargs acts as trim
latest_snapshot_diff=$(restic snapshots --tag "$RESTIC_BACKUP_TAG" --latest 2 --compact "${extra_args[@]}" \
snapshot_size=$(restic stats latest --tag "$RESTIC_BACKUP_TAG" | grep -i 'total size:' | cut -d ':' -f2 | xargs) # xargs acts as trim
latest_snapshot_diff=$(restic snapshots --tag "$RESTIC_BACKUP_TAG" --latest 2 --compact \
| grep -Ei "^[abcdef0-9]{8} " \
| awk '{print $1}' \
| tail -2 \
| tr '\n' ' ' \
| xargs restic diff "${extra_args[@]}")
| xargs restic diff)
added=$(echo "$latest_snapshot_diff" | grep -i 'added:' | awk '{print $2 " " $3}')
removed=$(echo "$latest_snapshot_diff" | grep -i 'removed:' | awk '{print $2 " " $3}')

View File

@@ -43,10 +43,3 @@ export RESTIC_RETENTION_YEARS=3
#RESTIC_BACKUP_EXTRA_ARGS="--exclude-file /path/to/extra/exclude/file/a --exclude-file /path/to/extra/exclude/file/b"
# Example: exclude all directories that have a .git/ directory inside it.
#RESTIC_BACKUP_EXTRA_ARGS="--exclude-if-present .git"
# Optional extra space-separated arguments to all restic commands, i.e. global arguments.
# Example: Limit download speed to a maximum of 1000 KiB/s
#RESTIC_EXTRA_ARGS="--limit-download 1000"
# Example: Set custom sftp parameters or a custom path.
#RESTIC_EXTRA_ARGS="--option sftp.command='ssh\ backup-host\ -s\ sftp'"