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
Commits
20d5853c
Commit
20d5853c
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix backups without transfer
parent
41077828
No related branches found
No related tags found
1 merge request
!36
fix backups without transfer
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
backup.sh
+43
-23
43 additions, 23 deletions
backup.sh
with
43 additions
and
23 deletions
backup.sh
+
43
−
23
View file @
20d5853c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
#
functions
#
FUNCTIONS
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
function
showHelp
(){
function
showHelp
(){
...
@@ -59,15 +59,13 @@ EOFhelp
...
@@ -59,15 +59,13 @@ EOFhelp
}
}
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
#
checks
#
MAIN
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
# --- read backup config data
# --- read schedulerdata
j_read
j_read
# --- handle params
while
[
"$#"
-gt
0
]
;
while
[
"$#"
-gt
0
]
;
do
do
...
@@ -120,10 +118,13 @@ do
...
@@ -120,10 +118,13 @@ do
done
done
# update logfile after param overrides
#
---
update logfile after param overrides
_j_setLogfile
_j_setLogfile
# --------------------------------------------------------------------------------
# show infos
# show infos
# --------------------------------------------------------------------------------
cfg_type
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"type"
)
cfg_type
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"type"
)
cfg_full
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"full"
)
cfg_full
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"full"
)
cfg_startfull
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"start-time-full"
)
cfg_startfull
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"start-time-full"
)
...
@@ -132,6 +133,7 @@ do
...
@@ -132,6 +133,7 @@ do
JOBDEF_STARTTIME
=
$(
date
+%H%M
)
JOBDEF_STARTTIME
=
$(
date
+%H%M
)
STORAGE_BIN
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"bin"
)
STORAGE_BIN
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"bin"
)
STORAGE_BASEDIR
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"storage"
)
cat
<<
EOFbackupinfo
cat
<<
EOFbackupinfo
...
@@ -142,11 +144,18 @@ do
...
@@ -142,11 +144,18 @@ do
EFFECTIVE:
EFFECTIVE:
type :
$JOBDEF_TYPE
$JOBDEF_AUTO
type :
$JOBDEF_TYPE
$JOBDEF_AUTO
donefile :
$JOB_DONEFILE
log :
$JOB_LOGFILE
log :
$JOB_LOGFILE
target :
${
STORAGE_BASEDIR
}
$(
test
-z
"
$STORAGE_BASEDIR
"
&&
echo
"NONE (local backup dumps only; no transfer)"
)
EOFbackupinfo
EOFbackupinfo
test
-z
"
$STORAGE_BASEDIR
"
||
(
echo
" dirs to transfer : "
j_getDirs2Backup |
sed
"s#^# #g"
echo
)
j_requireUser
"root"
j_requireUser
"root"
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
...
@@ -157,7 +166,9 @@ EOFbackupinfo
...
@@ -157,7 +166,9 @@ EOFbackupinfo
sleep
3
sleep
3
# ----- local dumps
# ------------------------------------------------------------
# local dumps
# ------------------------------------------------------------
echo
"INFO:
$(
date
)
- starting backup ... type
$JOBDEF_TYPE
- time
$JOBDEF_STARTTIME
"
|
tee
-a
"
$JOB_LOGFILE
"
echo
"INFO:
$(
date
)
- starting backup ... type
$JOBDEF_TYPE
- time
$JOBDEF_STARTTIME
"
|
tee
-a
"
$JOB_LOGFILE
"
touch
"
${
JOB_DONEFILE
}
.01.START"
touch
"
${
JOB_DONEFILE
}
.01.START"
...
@@ -168,12 +179,14 @@ EOFbackupinfo
...
@@ -168,12 +179,14 @@ EOFbackupinfo
"
${
DIR_SELF
}
"
/localdump.sh ALL |
tee
-a
"
$JOB_LOGFILE
"
"
${
DIR_SELF
}
"
/localdump.sh ALL |
tee
-a
"
$JOB_LOGFILE
"
rcBackup
=
$?
rcBackup
=
$?
echo
"INFO:
$(
date
)
- local backups were finished"
|
tee
-a
"
$JOB_LOGFILE
"
echo
"INFO:
$(
date
)
- local backups were finished"
|
tee
-a
"
$JOB_LOGFILE
"
echo
sleep
2
sleep
2
# ----- transfer
# ------------------------------------------------------------
# transfer
# ------------------------------------------------------------
if
[
-x
"
${
DIR_SELF
}
/transfer.sh"
]
;
then
if
[
-n
"
$STORAGE_BASEDIR
"
]
&&
[
-x
"
${
DIR_SELF
}
/transfer.sh"
]
;
then
# transfer files
# transfer files
cat
"
$STORAGEFILE
"
>>
"
$JOB_LOGFILE
"
cat
"
$STORAGEFILE
"
>>
"
$JOB_LOGFILE
"
...
@@ -184,15 +197,18 @@ EOFbackupinfo
...
@@ -184,15 +197,18 @@ EOFbackupinfo
rcTransfer
=
$?
rcTransfer
=
$?
else
else
echo
"SKIP -
transfer.sh not found; all files will be kept on local filesystem only
"
|
tee
-a
"
$JOB_LOGFILE
"
echo
"SKIP -
No backup of dirs to a backup target.
"
|
tee
-a
"
$JOB_LOGFILE
"
fi
fi
rcBackup
=
$rcBackup
+rcTransfer
rcBackup
=
$rcBackup
+rcTransfer
echo
"INFO:
$(
date
)
- DONE"
|
tee
-a
"
$JOB_LOGFILE
"
echo
"INFO:
$(
date
)
- DONE"
|
tee
-a
"
$JOB_LOGFILE
"
touch
"
${
JOB_DONEFILE
}
.03.DONE"
touch
"
${
JOB_DONEFILE
}
.03.DONE"
# ------------------------------------------------------------
# cleanup
# ------------------------------------------------------------
echo
echo
echo
"INFO:
$(
date
)
- compress older logs"
echo
"INFO:
$(
date
)
- compress older logs"
echo
find
"
${
DIR_LOGS
}
"
-name
"*.log"
-mtime
+2
-print
-exec
gzip
{}
\;
echo
find
"
${
DIR_LOGS
}
"
-name
"*.log"
-mtime
+2
-print
-exec
gzip
{}
\;
...
@@ -204,6 +220,10 @@ EOFbackupinfo
...
@@ -204,6 +220,10 @@ EOFbackupinfo
find
"
${
DIR_LOGS
}
"
-mtime
+28
-delete
-print
find
"
${
DIR_LOGS
}
"
-mtime
+28
-delete
-print
echo
echo
# ------------------------------------------------------------
# finish
# ------------------------------------------------------------
echo
STATUS
$0
exit
with final returncode
rc
=
$rcBackup
|
tee
-a
"
$JOB_LOGFILE
"
echo
STATUS
$0
exit
with final returncode
rc
=
$rcBackup
|
tee
-a
"
$JOB_LOGFILE
"
echo
echo
echo
"log for this executed job is"
echo
"log for this executed job is"
...
...
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