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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Iml Backup Server
Commits
ee9c0db0
Commit
ee9c0db0
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
backup status: check age of restic backups when not using ssh
parent
70055581
No related branches found
No related tags found
1 merge request
!7
backup status: check age of restic backups when not using ssh
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage_helper.sh
+130
-63
130 additions, 63 deletions
storage_helper.sh
with
130 additions
and
63 deletions
storage_helper.sh
+
130
−
63
View file @
ee9c0db0
...
...
@@ -33,6 +33,7 @@
# 2021-01-22 hahn show inactive backups in status page; colored lines by status
# 2021-11-12 hahn backup status: add handling for backup exitcode
# 2022-07-06 hahn backup status: show clear message on not started/ deleted backups
# 2024-03-22 hahn backup status: check age of restic backups when not using ssh
# ======================================================================
# ----------------------------------------------------------------------
...
...
@@ -124,7 +125,7 @@
# get content of all logfiles
function
_getAllLogs
(){
zcat
$sLogdir
/
*
.gz
;
cat
$sLogfile
ls
$sLogdir
/
*
.gz
>
/dev/null 2>&1
&&
(
zcat
$sLogdir
/
*
.gz
;
cat
$sLogfile
)
}
# get a list of all servers in the log
...
...
@@ -184,7 +185,7 @@
test
-f
"
$sTouchfile
"
&&
echo
1
test
-f
"
$sTouchfile
"
||
echo
0
}
# check if a backup for current server is
running
# check if a backup for current server is
inactive
# it returns 0 for no and 1 for yes
# global string sBackupClient FQDN of current server
# global string sBackupBasedir backup directory
...
...
@@ -197,6 +198,14 @@
fi
}
# get age of a file in sec
# param string filename to test
#
function
_getFileAge
(){
echo
$((
$(
date
+%s
)
-
$(
date
+%s
-r
"
$1
"
)
))
}
# ------------------------------------------------------------
# slot handling
# ------------------------------------------------------------
...
...
@@ -292,11 +301,68 @@
function
PUBLIC_backupstatus
(){
typeset
-i
local
ierrors
=
0
local
tbl
=
"%s %-45s | %-20s | %-20s | %8s | %3s | %7s | %s
\n
"
local
ierrors
;
typeset
-i
ierrors
=
0
local
tbl
# _showConnectionCount
echo
if
!
_getLoggedServers |
grep
-qc
.
;
then
iKeepBackups
=
180
local
iAgeH
;
typeset
-i
iAgeH
local
iAgeD
;
typeset
-i
iAgeD
local
sAge
local
mydir
local
bIsInactive
;
typeset
-i
bIsInactive
local
iCounter
;
typeset
-i
iCounter
=
0
echo
"Age of Restic backup repositories"
for
myresticsnapshotdir
in
$(
ls
-1trd
${
sBackupBasedir
}
/
*
/
*
/snapshots
)
do
iCounter
=
$iCounter
+1
mydir
=
$(
dirname
"
${
myresticsnapshotdir
}
"
)
sBackupClient
=
$(
basename
${
mydir
}
)
iAgeH
=
$(
_getFileAge
"
${
myresticsnapshotdir
}
"
)
/60/60
iAgeD
=
iAgeH/24
bIsInactive
=
$(
_isInactive
)
sMore
=
sStatus
=
"
$(
color ok
)
."
test
$bIsInactive
-eq
1
&&
sStatus
=
"
$(
color disabled
)
D"
sFile
=
${
mydir
}
/inactive.txt
if
[
"
$bIsInactive
"
-eq
"1"
]
;
then
typeset
-i
iAge
=
`
_getFileAge
"
$sFile
"
`
typeset
-i
iDays
=
$iKeepBackups
-
$iAge
/60/60/24
sMore
=
" - INFO: keeping it
$iKeepBackups
d ..
$iDays
d left."
if
[
"
$iDays
"
-lt
0
]
;
then
sMore
=
" - DELETE: overdued
$iDays
d."
sStatus
=
"
$(
color error
)
E"
ierrors
=
$ierrors
+1
fi
elif
[
$iAgeH
-ge
24
]
;
then
sStatus
=
"
$(
color error
)
E"
ierrors
=
$ierrors
+1
_showConnectionCount
fi
sAge
=
"
$iAgeH
h"
if
[
$iAgeH
-gt
96
]
;
then
sAge
=
"
$iAgeD
d"
fi
printf
"%2s %7s %s
\n
"
"
$sStatus
"
"
$sAge
"
"
${
mydir
}
$sMore
"
done
color reset
echo
echo
"Legend"
echo
". OK | D disabled | E error"
echo
echo
"total :
$iCounter
servers"
echo
"errors:
$ierrors
"
echo
else
tbl
=
"%s %-45s | %-20s | %-20s | %8s | %3s | %7s | %s
\n
"
echo
"This table shows the time and duration [s] of the last backup for each server."
echo
printf
"
$tbl
"
" "
"server"
"start"
"end"
"duration"
"rc"
"age [h]"
"size"
...
...
@@ -355,6 +421,7 @@
echo
"total :
$(
_getLoggedServers |
wc
-l
)
servers"
echo
"errors:
$ierrors
"
echo
fi
echo
"rc=
$ierrors
"
exit
$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