mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #310199 from symphorien/borg_ignore_warnings_master
nixos/borgbackup: add an option to ignore warnings
This commit is contained in:
commit
673f00ad7b
1 changed files with 26 additions and 6 deletions
|
@ -33,13 +33,24 @@ let
|
||||||
}
|
}
|
||||||
trap on_exit EXIT
|
trap on_exit EXIT
|
||||||
|
|
||||||
|
borgWrapper () {
|
||||||
|
local result
|
||||||
|
borg "$@" && result=$? || result=$?
|
||||||
|
if [[ -z "${toString cfg.failOnWarnings}" ]] && [[ "$result" == 1 ]]; then
|
||||||
|
echo "ignoring warning return value 1"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return "$result"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
archiveName="${optionalString (cfg.archiveBaseName != null) (cfg.archiveBaseName + "-")}$(date ${cfg.dateFormat})"
|
archiveName="${optionalString (cfg.archiveBaseName != null) (cfg.archiveBaseName + "-")}$(date ${cfg.dateFormat})"
|
||||||
archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}"
|
archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}"
|
||||||
${cfg.preHook}
|
${cfg.preHook}
|
||||||
'' + optionalString cfg.doInit ''
|
'' + optionalString cfg.doInit ''
|
||||||
# Run borg init if the repo doesn't exist yet
|
# Run borg init if the repo doesn't exist yet
|
||||||
if ! borg list $extraArgs > /dev/null; then
|
if ! borgWrapper list $extraArgs > /dev/null; then
|
||||||
borg init $extraArgs \
|
borgWrapper init $extraArgs \
|
||||||
--encryption ${cfg.encryption.mode} \
|
--encryption ${cfg.encryption.mode} \
|
||||||
$extraInitArgs
|
$extraInitArgs
|
||||||
${cfg.postInit}
|
${cfg.postInit}
|
||||||
|
@ -48,7 +59,7 @@ let
|
||||||
(
|
(
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
${optionalString (cfg.dumpCommand != null) ''${escapeShellArg cfg.dumpCommand} | \''}
|
${optionalString (cfg.dumpCommand != null) ''${escapeShellArg cfg.dumpCommand} | \''}
|
||||||
borg create $extraArgs \
|
borgWrapper create $extraArgs \
|
||||||
--compression ${cfg.compression} \
|
--compression ${cfg.compression} \
|
||||||
--exclude-from ${mkExcludeFile cfg} \
|
--exclude-from ${mkExcludeFile cfg} \
|
||||||
--patterns-from ${mkPatternsFile cfg} \
|
--patterns-from ${mkPatternsFile cfg} \
|
||||||
|
@ -57,16 +68,16 @@ let
|
||||||
${if cfg.paths == null then "-" else escapeShellArgs cfg.paths}
|
${if cfg.paths == null then "-" else escapeShellArgs cfg.paths}
|
||||||
)
|
)
|
||||||
'' + optionalString cfg.appendFailedSuffix ''
|
'' + optionalString cfg.appendFailedSuffix ''
|
||||||
borg rename $extraArgs \
|
borgWrapper rename $extraArgs \
|
||||||
"::$archiveName$archiveSuffix" "$archiveName"
|
"::$archiveName$archiveSuffix" "$archiveName"
|
||||||
'' + ''
|
'' + ''
|
||||||
${cfg.postCreate}
|
${cfg.postCreate}
|
||||||
'' + optionalString (cfg.prune.keep != { }) ''
|
'' + optionalString (cfg.prune.keep != { }) ''
|
||||||
borg prune $extraArgs \
|
borgWrapper prune $extraArgs \
|
||||||
${mkKeepArgs cfg} \
|
${mkKeepArgs cfg} \
|
||||||
${optionalString (cfg.prune.prefix != null) "--glob-archives ${escapeShellArg "${cfg.prune.prefix}*"}"} \
|
${optionalString (cfg.prune.prefix != null) "--glob-archives ${escapeShellArg "${cfg.prune.prefix}*"}"} \
|
||||||
$extraPruneArgs
|
$extraPruneArgs
|
||||||
borg compact $extraArgs $extraCompactArgs
|
borgWrapper compact $extraArgs $extraCompactArgs
|
||||||
${cfg.postPrune}
|
${cfg.postPrune}
|
||||||
'');
|
'');
|
||||||
|
|
||||||
|
@ -488,6 +499,15 @@ in {
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
failOnWarnings = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Fail the whole backup job if any borg command returns a warning
|
||||||
|
(exit code 1), for example because a file changed during backup.
|
||||||
|
'';
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
doInit = mkOption {
|
doInit = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
description = ''
|
description = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue