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
55f2cd73
Commit
55f2cd73
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update status
parent
fb420791
No related branches found
No related tags found
1 merge request
!6
Add prune script
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rest_pruner.sh
+22
-9
22 additions, 9 deletions
rest_pruner.sh
with
22 additions
and
9 deletions
rest_pruner.sh
+
22
−
9
View file @
55f2cd73
...
@@ -7,11 +7,12 @@
...
@@ -7,11 +7,12 @@
# 2024-02-01 v0.1 <axel.hahn@unibe.ch> first lines
# 2024-02-01 v0.1 <axel.hahn@unibe.ch> first lines
# 2024-02-02 v0.2 <axel.hahn@unibe.ch> add: timer, skip file, skin N days, limit process time, stats
# 2024-02-02 v0.2 <axel.hahn@unibe.ch> add: timer, skip file, skin N days, limit process time, stats
# 2024-02-03 v0.3 <axel.hahn@unibe.ch> enable cache dir; unlock before pruning
# 2024-02-03 v0.3 <axel.hahn@unibe.ch> enable cache dir; unlock before pruning
# 2024-02-14 v0.4 <axel.hahn@unibe.ch> update status
# ======================================================================
# ======================================================================
cd
"
$(
dirname
$0
)
"
||
exit
cd
"
$(
dirname
$0
)
"
||
exit
_version
=
0.
3
_version
=
0.
4
logdir
=
_last_prune
logdir
=
_last_prune
prune_basedir
=
prune_basedir
=
...
@@ -181,6 +182,9 @@ function _prune(){
...
@@ -181,6 +182,9 @@ function _prune(){
if
[
"
$rc
"
-eq
"0"
]
;
then
if
[
"
$rc
"
-eq
"0"
]
;
then
mv
"
${
logfile
}
.running"
"
${
logfile
}
"
mv
"
${
logfile
}
.running"
"
${
logfile
}
"
iCountPrune+
=
1
iCountPrune+
=
1
# remove last error file if run was ok now
test
-f
"
${
logfile
}
.error"
&&
rm
-f
"
${
logfile
}
.error"
else
else
iCountPruneError+
=
1
iCountPruneError+
=
1
mv
"
${
logfile
}
.running"
"
${
logfile
}
.error"
mv
"
${
logfile
}
.running"
"
${
logfile
}
.error"
...
@@ -206,7 +210,7 @@ function _status(){
...
@@ -206,7 +210,7 @@ function _status(){
_processes
=
"
$(
ps
-eo
command
)
"
_processes
=
"
$(
ps
-eo
command
)
"
echo
"Prune status:"
echo
"Prune status:"
for
_dir
in
$(
find
${
prune_basedir
}
-maxdepth
1
-type
d |
grep
-E
"
$filter
"
)
for
_dir
in
$(
find
${
prune_basedir
}
-maxdepth
1
-type
d |
grep
-E
"
$filter
"
|
sort
)
do
do
local
mybase
;
mybase
=
$(
basename
"
${
_dir
}
"
)
local
mybase
;
mybase
=
$(
basename
"
${
_dir
}
"
)
local
mypw
;
mypw
=
$(
grep
"^
${
mybase
}
:"
"
${
cfgfile
}
"
|
cut
-f2
-d
':'
)
local
mypw
;
mypw
=
$(
grep
"^
${
mybase
}
:"
"
${
cfgfile
}
"
|
cut
-f2
-d
':'
)
...
@@ -218,30 +222,38 @@ function _status(){
...
@@ -218,30 +222,38 @@ function _status(){
local
_flagRunning
=
"."
local
_flagRunning
=
"."
local
_flagError
=
"."
local
_flagError
=
"."
local
_sLastPrune
=
"?"
local
_sLastPrune
=
"?"
local
_iAge
local
_iDays
iCountDirs+
=
1
iCountDirs+
=
1
test
-n
"
$mypw
"
&&
_flagPw
=
"Y"
test
-n
"
$mypw
"
&&
_flagPw
=
"Y"
grep
"
\.
"
<<<
"
$mybase
"
>
/dev/null
&&
_flagPw
=
"."
test
-f
"
$_dir
/
${
sSkipfile
}
"
&&
_flagArchive
=
"A"
test
-f
"
$_dir
/
${
sSkipfile
}
"
&&
_flagArchive
=
"A"
test
-f
"
${
logfile
}
.error"
&&
_flagError
=
"E"
test
-f
"
${
logfile
}
.error"
&&
_flagError
=
"E"
test
-f
"
${
logfile
}
.error"
&&
iCountPruneError+
=
1
grep
"restic forget.*
${
_dir
}
"
<<<
"
$_processes
"
|
grep
-v
"grep"
|
grep
.
>
/dev/null
&&
_flagRunning
=
"R"
grep
"restic forget.*
${
_dir
}
"
<<<
"
$_processes
"
|
grep
-v
"grep"
|
grep
.
>
/dev/null
&&
_flagRunning
=
"R"
if
[
-f
"
${
logfile
}
"
]
;
then
if
[
-f
"
${
logfile
}
"
]
;
then
local
_iAge
;
_iAge
=
$(
_getFileAge
"
${
logfile
}
"
)
_iAge
=
$(
_getFileAge
"
${
logfile
}
"
)
local
_iDays
;
typeset
-i
_iDays
=
$((
_iAge/60/60/24
))
typeset
-i
_iDays
=
$((
_iAge/60/60/24
))
_sLastPrune
=
"
$_iDays
days ago"
_sLastPrune
=
"
$_iDays
d ago"
test
"
$_iDays
"
-eq
"0"
&&
_sLastPrune
=
"today"
fi
fi
if
[
-n
"
$mypw
"
]
||
[
"
$_flagArchive
"
=
"A"
]
||
[
"
$bOptAll
"
-eq
"1"
]
;
then
if
[
-n
"
$mypw
"
]
||
[
"
$_flagArchive
"
=
"A"
]
||
[
"
$bOptAll
"
-eq
"1"
]
;
then
iCountMatch+
=
1
iCountMatch+
=
1
printf
"%1s %1s %1s %1s %-
12
s %s
\n
"
"
$_flagPw
"
"
$_flagArchive
"
"
$_flagError
"
"
$_flagRunning
"
"
$_sLastPrune
"
"
$_dir
"
printf
"%1s %1s %1s %1s %-
9
s %s
\n
"
"
$_flagPw
"
"
$_flagArchive
"
"
$_flagError
"
"
$_flagRunning
"
"
$_sLastPrune
"
"
$_dir
"
fi
fi
done
done
if
[
"
$iCountMatch
"
-gt
"0"
]
;
then
if
[
"
$iCountMatch
"
-gt
"0"
]
;
then
echo
echo
echo
": : : : :
:"
echo
": : : : : :"
echo
": : : : :
+-- repository dir"
echo
": : : : : +-- repository dir"
echo
": : : : +-- last successful prune"
echo
": : : : +-- last successful prune"
echo
": : : +-- is it currently running?"
echo
": : : +-- is it currently running?"
echo
": : +-- Last prune on error?"
echo
": : +-- Last prune on error?"
...
@@ -251,6 +263,7 @@ function _status(){
...
@@ -251,6 +263,7 @@ function _status(){
echo
"INFO: No (matching) Repository was found."
echo
"INFO: No (matching) Repository was found."
fi
fi
echo
echo
}
}
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# MAIN
# MAIN
...
@@ -367,7 +380,7 @@ do
...
@@ -367,7 +380,7 @@ do
_prune
"
${
mydir
}
"
_prune
"
${
mydir
}
"
done
done
test
"
$bOptStats
"
-eq
"0"
&&
cat
<<
ENDSTATS
cat
<<
ENDSTATS
Statistics:
Statistics:
...
...
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