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
dc40e176
Commit
dc40e176
authored
2 years ago
by
Axel Hahn
Browse files
Options
Downloads
Patches
Plain Diff
add execution of hooks
parent
7410832c
No related branches found
No related tags found
1 merge request
!80
Add hooks
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
backup.sh
+1
-8
1 addition, 8 deletions
backup.sh
jobhelper.sh
+23
-7
23 additions, 7 deletions
jobhelper.sh
localdump.sh
+3
-1
3 additions, 1 deletion
localdump.sh
plugins/transfer/restic.sh
+3
-0
3 additions, 0 deletions
plugins/transfer/restic.sh
transfer.sh
+12
-1
12 additions, 1 deletion
transfer.sh
with
42 additions
and
17 deletions
backup.sh
+
1
−
8
View file @
dc40e176
...
...
@@ -176,7 +176,7 @@ EOFbackupinfo
if
[
$bStart
-eq
1
]
;
then
_j_runHooks
"
hooks/
10-before-backup
/always
"
_j_runHooks
"10-before-backup"
sleep
3
...
...
@@ -190,16 +190,9 @@ EOFbackupinfo
echo
"INFO:
$(
date
)
- Making local backups ...
${
DIR_SELF
}
/localdump.sh ALL"
|
tee
-a
"
$JOB_LOGFILE
"
_j_runHooks
"hooks/12-before-db-service/always"
"
${
DIR_SELF
}
"
/localdump.sh ALL |
tee
-a
"
$JOB_LOGFILE
"
rcBackup
=
$?
if
[
$rcBackup
-eq
0
]
;
then
_j_runHooks
"hooks/18-after-db-service/on-ok"
else
_j_runHooks
"hooks/18-after-db-service/on-error"
fi
_j_runHooks
"hooks/18-after-db-service/always"
echo
"INFO:
$(
date
)
- local backups were finished"
|
tee
-a
"
$JOB_LOGFILE
"
echo
...
...
This diff is collapsed.
Click to expand it.
jobhelper.sh
+
23
−
7
View file @
dc40e176
...
...
@@ -181,22 +181,38 @@ function _j_getvar(){
# ------------------------------------------------------------
# execute hook skripts in a given directory in alphabetic order
# param string name of hook directory
# param string name of hook directory
# param string optional: integer of existcode or "" for non-on-result hook
# ------------------------------------------------------------
function
_j_runHooks
(){
local
_hookdir
=
$1
echo
echo
">>> HOOKS
$_hookdir
"
local
_hookbase
=
"
$1
"
local
_exitcode
=
"
$2
"
local
_hookdir
=
"hooks/
$_hookbase
"
if
[
-z
"
$_exitcode
"
]
;
then
_hookdir
=
"
$_hookdir
/always"
elif
[
"
$_exitcode
"
=
"0"
]
;
then
_hookdir
=
"
$_hookdir
/on-ok"
else
_hookdir
=
"
$_hookdir
/on-error"
fi
for
hookscript
in
$(
ls
-1a
"
$_hookdir
"
|
grep
-v
"^
\.
*$"
|
sort
)
do
if
[
-x
"
$hookscript
"
]
;
then
echo
"start
$hookscript
..."
echo
"
>>> HOOKS
$_hookdir
start
$hookscript
..."
$hookscript
else
echo
"SKIP:
$hookscript
(not executable)"
#
else
#
echo "SKIP: $hookscript (not executable)"
fi
done
# if an exitcode was given as param then run hooks without exitcode
# (in subdir "always")
if
[
-n
"
$_exitcode
"
]
;
then
_j_runHooks
"
$_hookbase
"
fi
echo
}
...
...
This diff is collapsed.
Click to expand it.
localdump.sh
+
3
−
1
View file @
dc40e176
...
...
@@ -204,7 +204,7 @@
if
[
-d
"
${
BACKUP_TARGETDIR
}
"
]
;
then
cd
"
${
BACKUP_TARGETDIR
}
"
if
[
-z
$1
]
;
then
find
-type
f |
sed
"s#__[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9].*##g"
|
grep
-v
".meta"
|
sort
-ud
|
sed
"s#^
\.
/##g"
find
-type
f |
sed
"s#__[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9].*##g"
|
grep
-v
"
\
.
meta"
|
sort
-ud
|
sed
"s#^
\.
/##g"
else
ls
-ltr
"
$*
__"
*
|
sed
"s#^
\.
/##g"
fi
...
...
@@ -354,7 +354,9 @@
# ----- start service specific script
h2
"START SCRIPT FOR
${
SERVICENAME
}
-
$BACKUP_SCRIPT
"
_j_runHooks
"12-before-db-service"
.
$BACKUP_SCRIPT
$mode
_j_runHooks
"18-after-db-service"
"
$rc
"
# ----- post jobs: cleanup
cleanup_backup_target
...
...
This diff is collapsed.
Click to expand it.
plugins/transfer/restic.sh
+
3
−
0
View file @
dc40e176
...
...
@@ -213,6 +213,8 @@
color reset
t_rcCheckPrune
$_myrc
_j_runHooks
"26-after-prune"
"
$_myrc
"
echo
}
# verify backup data
...
...
@@ -231,6 +233,7 @@
color reset
t_rcCheckVerify
$_myrc
_j_runHooks
"28-after-verify"
"
$_myrc
"
echo
}
...
...
This diff is collapsed.
Click to expand it.
transfer.sh
+
12
−
1
View file @
dc40e176
...
...
@@ -219,13 +219,14 @@ function setAction(){
fi
.
`
dirname
$0
`
/plugins/transfer/
$STORAGE_BIN
.sh
||
exit
1
test
-z
"
$STORAGE_REGISTER
"
||
.
`
dirname
$0
`
/plugins/register/
$STORAGE_REGISTER
.sh
||
exit
1
# --------------------------------------------------------------------------------
# ----- Check requirements
t_checkRequirements
||
exit
1
test
-z
"
$STORAGE_REGISTER
"
||
.
`
dirname
$0
`
/plugins/register/
$STORAGE_REGISTER
.sh
||
exit
1
echo
Check locking of a running transfer
if
[
-f
"
${
lockfile
}
"
]
;
then
color error
...
...
@@ -268,6 +269,8 @@ function setAction(){
exit
2
fi
_j_runHooks
"20-before-transfer"
# --------------------------------------------------------------------------------
# ----- BACKUP VARS
...
...
@@ -379,6 +382,9 @@ function setAction(){
if
[
$doBackup
-eq
0
]
;
then
echo
"SKIP backup"
else
_j_runHooks
"22-before-folder-transfer"
sCmd
=
"
$(
t_backupDirGetCmdBackup
)
"
echo
"what:
${
BACKUP_DIR
}
"
echo
"target:
${
sTarget
}
"
|
sed
's#:[^:]*@#:**********@#'
...
...
@@ -391,6 +397,7 @@ function setAction(){
echo
t_rcCheckBackup
$myrc
"
${
BACKUP_DIR
}
"
_j_runHooks
"24-after-folder-transfer"
"
$myrc
"
fi
echo
...
...
@@ -410,6 +417,8 @@ function setAction(){
fi
echo
done
else
echo
"SKIP backup of dirs"
fi
# --- prune
...
...
@@ -469,6 +478,8 @@ function setAction(){
echo
Backup FAILED :-/
fi
color reset
_j_runHooks
"30-post-backup"
"
$rc
"
echo
typeset
-i
TIMER_TRANSFER
=
`
date
+%s
`
-
$TIMER_TRANSFER_START
echo
`
date
`
$ACTION
DONE
in
$TIMER_TRANSFER
sec
...
...
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