Skip to content
Snippets Groups Projects
Commit 55f2cd73 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update status

parent fb420791
Branches
No related tags found
1 merge request!6Add prune script
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
...@@ -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,23 +222,31 @@ function _status(){ ...@@ -218,23 +222,31 @@ 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 %-12s %s\n" "$_flagPw" "$_flagArchive" "$_flagError" "$_flagRunning" "$_sLastPrune" "$_dir" printf "%1s %1s %1s %1s %-9s %s\n" "$_flagPw" "$_flagArchive" "$_flagError" "$_flagRunning" "$_sLastPrune" "$_dir"
fi fi
done done
...@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment