Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Commits
6276b6a2
Commit
6276b6a2
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
simplify restic exec commands in _restic
parent
41454ff9
No related branches found
No related tags found
1 merge request
!87
5814 migrate repo to v2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/transfer/restic.sh
+32
-41
32 additions, 41 deletions
plugins/transfer/restic.sh
with
32 additions
and
41 deletions
plugins/transfer/restic.sh
+
32
−
41
View file @
6276b6a2
...
...
@@ -14,6 +14,7 @@
# 2022-03-07 ah v0.4 add verify in post task
# 2022-05-10 ah v0.5 fix handling with nocache flag (use globally as default param - not in backup only)
# 2022-05-16 ah v0.6 added restic prune
# 2022-10-21 ah v0.7 simplify restic exec commands in _restic; remove --prune in check
# ================================================================================
# --------------------------------------------------------------------------------
...
...
@@ -119,6 +120,19 @@
fi
}
# execute a restic command
# param string options and subcommand
function
_restic
(){
local
_mycmd
=
"restic
$*
${
ARGS_DEFAULT
}
"
echo
"
$_mycmd
"
sleep
3
color cmd
eval
"
$_mycmd
"
local
_myrc
=
$?
color reset
return
$_myrc
}
# --------------------------------------------------------------------------------
# BACKUP ACTIONS :: TRANSFER
# --------------------------------------------------------------------------------
...
...
@@ -127,30 +141,22 @@
# function t_backupDoPreTasks(){
function
t_backupDoPreTasks
(){
if
eval
restic snapshots
${
ARGS_DEFAULT
}
>
/dev/null 2>&1
# if eval restic snapshots ${ARGS_DEFAULT} >/dev/null 2>&1
if
_restic list keys
>
/dev/null 2>&1
then
echo
"__REPO__ OK, Backup repository already exists."
echo
"--- UNLOCK ... just in case :-)"
eval
restic unlock
${
ARGS_DEFAULT
}
color reset
_restic unlock
echo
else
echo
"Backup repository needs to be created."
local
_mycmd
=
"restic init
${
ARGS_DEFAULT
}
"
echo
$_mycmd
color cmd
eval
$_mycmd
_restic init
local
_myrc
=
$?
color reset
# detect return code ... and abort on any error.
t_rcCheckInit
$_myrc
fi
echo
restic unlock
${
ARGS_DEFAULT
}
color cmd
eval
restic unlock
${
ARGS_DEFAULT
}
color reset
echo
}
...
...
@@ -161,26 +167,23 @@
# --------------------
echo
"--- UNLOCK ... just in case :-)"
echo
restic unlock
${
ARGS_DEFAULT
}
color cmd
eval
restic unlock
${
ARGS_DEFAULT
}
color reset
_restic unlock
echo
}
# prune old data
# uses global vars from ../../transfer.sh
# return exitcode of restic prune
function
t_backupDoPrune
(){
# --------------------
echo
"--- FORGET (in all pathes of repository)"
local
_tag
=
$(
_j_getvar
${
STORAGEFILE
}
"
${
CFGPREFIX
}
tag"
)
local
_mycmd
=
"
restic
forget
\
local
_mycmd
=
"forget
\
${
ARGS_DEFAULT
}
\
--tag
$_tag
\
--group-by paths,tags
\
--prune
\
--cleanup-cache"
local
_keep
...
...
@@ -192,49 +195,39 @@
fi
done
echo
$_mycmd
sleep
3
color cmd
eval
$_mycmd
local
_myrc
=
$?
color reset
_restic
"
$_mycmd
"
_myrc
=
$?
t_rcCheckCleanup
$_myrc
echo
# --------------------
echo
"--- PRUNE (whole repository)"
_mycmd
=
"restic prune
${
ARGS_DEFAULT
}
"
echo
$_mycmd
sleep
3
color cmd
eval
$_mycmd
local
_myrc
=
$?
color reset
_restic prune
_myrc
=
$?
t_rcCheckPrune
$_myrc
_j_runHooks
"26-after-prune"
"
$_myrc
"
echo
return
$_myrc
}
# verify backup data
# uses global vars from ../../transfer.sh
# return exitcode of restic check
function
t_backupDoVerify
(){
# --------------------
echo
"--- VERIFY (whole repository)"
# param --read-data takes a long time. Maybe use an extra job with it.
# _mycmd="time restic check ${ARGS_DEFAULT} --with-cache --read-data"
_mycmd
=
"restic check
${
ARGS_DEFAULT
}
--with-cache"
echo
$_mycmd
sleep
3
color cmd
eval
$_mycmd
local
_myrc
=
$?
color reset
_restic check
--with-cache
_myrc
=
$?
t_rcCheckVerify
$_myrc
_j_runHooks
"28-after-verify"
"
$_myrc
"
echo
return
$_myrc
}
# --------------------------------------------------------------------------------
...
...
@@ -280,9 +273,7 @@
if
[
"
${
_snapshotLast
}
"
=
"
${
_snapshotNow
}
"
]
;
then
echo
"This was the initial (full) Backup"
else
color cmd
eval
restic diff
${
ARGS_DEFAULT
}
"
${
_snapshotLast
}
"
"
${
_snapshotNow
}
"
color reset
_restic diff
"
${
_snapshotLast
}
"
"
${
_snapshotNow
}
"
fi
echo
...
...
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