Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Gervais
backupninja
Commits
97153e44
Commit
97153e44
authored
Feb 21, 2017
by
Christopher Gervais
Browse files
Options
Downloads
Patches
Plain Diff
Remove duplication in setting 'keep' parameters.
parent
8272e549
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
handlers/restic.in
+18
-42
18 additions, 42 deletions
handlers/restic.in
with
18 additions
and
42 deletions
handlers/restic.in
+
18
−
42
View file @
97153e44
...
@@ -116,50 +116,26 @@ if [[ "$retention" == "yes" ]]; then
...
@@ -116,50 +116,26 @@ if [[ "$retention" == "yes" ]]; then
fi
fi
fi
fi
if
[
$keep_hourly
]
;
then
declare
-A
range_array
if
[[
$keep_hourly
=
~ ^[0-9]+
$
]]
;
then
range_array[
'hourly'
]=
"hour"
debug
"==> For the last
$keep_hourly
hours in which a snapshot was made, keep only the last snapshot for each hour."
range_array[
'daily'
]=
"day"
keep_options
=
"
$keep_options
--keep-hourly
$keep_hourly
"
range_array[
'weekly'
]=
"week"
range_array[
'monthly'
]=
"month"
range_array[
'yearly'
]=
"year"
for
range
in
"
${
!range_array[@]
}
"
;
do
keep_range
=
"keep_
${
range
}
"
keep_unit
=
"
${
range_array
[
$range
]
}
"
if
[
"
${
!keep_range
}
"
]
;
then
if
[[
"
${
!keep_range
}
"
=
~ ^[0-9]+
$
]]
;
then
debug
"==> For the last
${
!keep_range
}
${
keep_unit
}
s in which a snapshot was made, keep only the last snapshot for each
${
keep_unit
}
."
keep_options
=
"
$keep_options
--keep-
$range
${
!keep_range
}
"
else
else
fatal
"If 'keep_
hourly
' is set, it must be an integer."
fatal
"If 'keep_
$range
' is set, it must be an integer."
fi
fi
fi
fi
if
[
$keep_daily
]
;
then
done
if
[[
$keep_daily
=
~ ^[0-9]+
$
]]
;
then
debug
"==> For the last
$keep_daily
days which have one or more snapshots, only keep the last one for that day."
keep_options
=
"
$keep_options
--keep-daily
$keep_daily
"
else
fatal
"If 'keep_daily' is set, it must be an integer."
fi
fi
if
[
$keep_weekly
]
;
then
if
[[
$keep_weekly
=
~ ^[0-9]+
$
]]
;
then
debug
"==> For the last
$keep_weekly
weeks which have one or more snapshots, only keep the last one for that week."
keep_options
=
"
$keep_options
--keep-weekly
$keep_weekly
"
else
fatal
"If 'keep_weekly' is set, it must be an integer."
fi
fi
if
[
$keep_monthly
]
;
then
if
[[
$keep_monthly
=
~ ^[0-9]+
$
]]
;
then
debug
"==> For the last
$keep_monthly
months which have one or more snapshots, only keep the last one for that month."
keep_options
=
"
$keep_options
--keep-monthly
$keep_monthly
"
else
fatal
"If 'keep_monthly' is set, it must be an integer."
fi
fi
if
[
$keep_yearly
]
;
then
if
[[
$keep_yearly
=
~ ^[0-9]+
$
]]
;
then
debug
"==> For the last
$keep_yearly
years which have one or more snapshots, only keep the last one for that year."
keep_options
=
"
$keep_options
--keep-yearly
$keep_yearly
"
else
fatal
"If 'keep_yearly' is set, it must be an integer."
fi
fi
if
[
$keep_tag
]
;
then
if
[
$keep_tag
]
;
then
for
tag
in
$keep_tag
for
tag
in
$keep_tag
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment