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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Merge requests
!87
5814 migrate repo to v2
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
5814 migrate repo to v2
5814-migrate-repo-to-v2
into
master
Overview
0
Commits
2
Pipelines
0
Changes
2
Merged
Hahn Axel (hahn)
requested to merge
5814-migrate-repo-to-v2
into
master
2 years ago
Overview
0
Commits
2
Pipelines
0
Changes
2
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d9305959
2 commits,
2 years ago
2 files
+
126
−
119
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
plugins/transfer/restic.sh
+
32
−
41
View file @ d9305959
Edit in single-file editor
Open in Web IDE
Show full file
@@ -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
Loading