Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Iml Backup Server
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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 Server
Commits
7e5735a2
Commit
7e5735a2
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
show inactive backups in status page; colored lines by status
parent
43f0507b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage_helper.sh
+45
-12
45 additions, 12 deletions
storage_helper.sh
with
45 additions
and
12 deletions
storage_helper.sh
+
45
−
12
View file @
7e5735a2
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
# 2021-06-16 hahn added backupstatus
# 2021-06-16 hahn added backupstatus
# 2021-06-18 hahn store backup status in status files ... do not grep frpom logs
# 2021-06-18 hahn store backup status in status files ... do not grep frpom logs
# 2021-06-21 hahn use single status file; added backup size
# 2021-06-21 hahn use single status file; added backup size
# 2021-01-22 hahn show inactive backups in status page; colored lines by status
# ======================================================================
# ======================================================================
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -72,6 +73,12 @@
...
@@ -72,6 +73,12 @@
;;
;;
"error"
)
sColorcode
=
"91"
# red
"error"
)
sColorcode
=
"91"
# red
;;
;;
"warn"
)
sColorcode
=
"33"
# yellow
;;
"active"
)
sColorcode
=
"94"
# light blue
;;
"disabled"
)
sColorcode
=
"90"
# gray
;;
esac
esac
if
[
!
-z
${
sColorcode
}
]
;
then
if
[
!
-z
${
sColorcode
}
]
;
then
echo
-ne
"
\e
[
${
sColorcode
}
m"
echo
-ne
"
\e
[
${
sColorcode
}
m"
...
@@ -174,7 +181,18 @@
...
@@ -174,7 +181,18 @@
test
-f
"
$sTouchfile
"
&&
echo
1
test
-f
"
$sTouchfile
"
&&
echo
1
test
-f
"
$sTouchfile
"
||
echo
0
test
-f
"
$sTouchfile
"
||
echo
0
}
}
# check if a backup for current server is running
# it returns 0 for no and 1 for yes
# global string sBackupClient FQDN of current server
# global string sBackupBasedir backup directory
function
_isInactive
(){
ls
${
sBackupBasedir
}
/
*
/
$sBackupClient
/inactive.txt
>
/dev/null 2>/dev/null
if
[
$?
-eq
0
]
;
then
echo
1
else
echo
0
fi
}
# ------------------------------------------------------------
# ------------------------------------------------------------
# slot handling
# slot handling
...
@@ -253,6 +271,7 @@
...
@@ -253,6 +271,7 @@
# test -r "$sStatusDir/${sBackupClient}" && . "$sStatusDir/${sBackupClient}"
# test -r "$sStatusDir/${sBackupClient}" && . "$sStatusDir/${sBackupClient}"
}
}
# list repositories ... used in setactive/ setinactive
function
_listRepodirs
(){
function
_listRepodirs
(){
for
mydir
in
$(
ls
-1d
${
sBackupBasedir
}
/
*
/
*
|
grep
-vE
'(_active|somethinglsetodisable)'
)
for
mydir
in
$(
ls
-1d
${
sBackupBasedir
}
/
*
/
*
|
grep
-vE
'(_active|somethinglsetodisable)'
)
do
do
...
@@ -271,13 +290,13 @@
...
@@ -271,13 +290,13 @@
function
PUBLIC_backupstatus
(){
function
PUBLIC_backupstatus
(){
typeset
-i
local
ierrors
=
0
typeset
-i
local
ierrors
=
0
local
tbl
=
"%-45s | %-20s | %-20s | %8s | %3s | %7s | %s
\n
"
local
tbl
=
"
%s
%-45s | %-20s | %-20s | %8s | %3s | %7s | %s
\n
"
_showConnectionCount
_showConnectionCount
echo
echo
echo
"This table shows the time and duration [s] of the last backup for each server."
echo
"This table shows the time and duration [s] of the last backup for each server."
echo
echo
printf
"
$tbl
"
"
server"
"start"
"end"
"duration"
"rc"
"age [h]"
"size"
printf
"
$tbl
"
"
"
"
server"
"start"
"end"
"duration"
"rc"
"age [h]"
"size"
echo
"-----------------------------------------------------------------------------------------------------------------------------"
echo
"-----------------------------------------------------------------------------------------------------------------------------"
for
myserver
in
$(
_getLoggedServers
)
for
myserver
in
$(
_getLoggedServers
)
do
do
...
@@ -286,6 +305,7 @@
...
@@ -286,6 +305,7 @@
typeset
-i
local
istart
=
"
$(
_getLastBackupstart
)
"
typeset
-i
local
istart
=
"
$(
_getLastBackupstart
)
"
typeset
-i
local
iend
=
"
$(
_getLastBackupend
)
"
typeset
-i
local
iend
=
"
$(
_getLastBackupend
)
"
typeset
-i
local
bIsRunning
=
$(
_isRunning
)
typeset
-i
local
bIsRunning
=
$(
_isRunning
)
typeset
-i
local
bIsInactive
=
$(
_isInactive
)
typeset
-i
local
iLastStatus
=
$(
_getLastBackupstatus
)
typeset
-i
local
iLastStatus
=
$(
_getLastBackupstatus
)
local
size
=
$(
_getBackupsize
)
local
size
=
$(
_getBackupsize
)
...
@@ -295,21 +315,34 @@
...
@@ -295,21 +315,34 @@
typeset
-i
local
iage
=
$(
date
+%s
)
-
${
iend
}
typeset
-i
local
iage
=
$(
date
+%s
)
-
${
iend
}
typeset
-i
local
iagehours
=
$iage
/60/60
typeset
-i
local
iagehours
=
$iage
/60/60
# check values
if
[
$iagehours
-gt
$iMaxbackupAge
]
;
then
ierrors
=
$ierrors
+1
fi
local
sduration
=
$iduration
local
sduration
=
$iduration
test
$iduration
-lt
0
&&
sduration
=
"RUNNING"
test
$iduration
-lt
0
&&
sduration
=
"RUNNING"
sStatusRun
=
"."
sStatusRun
=
"
$(
color ok
)
."
test
$iend
-eq
0
&&
sStatusRun
=
"?"
test
$iend
-eq
0
&&
sStatusRun
=
"
$(
color warn
)
?"
test
$bIsRunning
-eq
1
&&
sStatusRun
=
"R"
test
$bIsRunning
-eq
1
&&
sStatusRun
=
"
$(
color active
)
R"
test
$bIsInactive
-eq
1
&&
sStatusRun
=
"
$(
color disabled
)
D"
# check values
if
[
$iend
-gt
0
-a
$iagehours
-gt
$iMaxbackupAge
-a
$bIsInactive
-eq
0
]
;
then
ierrors
=
$ierrors
+1
sStatusRun
=
"
$(
color error
)
E"
fi
if
[
$iend
-eq
0
]
;
then
tstart
=
"-"
tend
=
"-"
sduration
=
""
iagehours
=
""
fi
# output
# output
printf
"
$tbl
"
"
$sStatusRun
$myserver
"
"
${
tstart
}
"
"
${
tend
}
"
"
${
sduration
}
"
"
$iLastStatus
"
"
${
iagehours
}
"
"
$size
"
printf
"
$tbl
"
"
$sStatusRun
"
"
$myserver
"
"
${
tstart
}
"
"
${
tend
}
"
"
${
sduration
}
"
"
$iLastStatus
"
"
${
iagehours
}
"
"
$size
"
done
done
color reset
echo
echo
"Legend"
echo
". OK | ? not started | R running | D disabled | E error"
echo
echo
echo
"total :
$(
_getLoggedServers |
wc
-l
)
servers"
echo
"total :
$(
_getLoggedServers |
wc
-l
)
servers"
echo
"errors:
$ierrors
"
echo
"errors:
$ierrors
"
...
...
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