Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
  • iml-open-source/iml-backup-server
1 result
Select Git revision
  • master
1 result
Show changes
Commits on Source (3)
...@@ -137,7 +137,7 @@ The inc_config.sh mus contain 3 variables for pruning ...@@ -137,7 +137,7 @@ The inc_config.sh mus contain 3 variables for pruning
```bash ```bash
# for prune on restic rest server # for prune on restic rest server
prune_basedir=/netshare/restic-backup prune_basedir=/netshare/restic-backup
prune_params="--group-by paths,tags --prune --keep-within 180d --max-unused unlimited --max-repack-size 100M --cleanup-cache" prune_params="--group-by paths,tags --prune --keep-within 180d --max-unused unlimited --max-repack-size 10G --cleanup-cache"
prune_skipdays="7" prune_skipdays="7"
prune_cachedir=${prune_basedir}/.cache_for_pruning prune_cachedir=${prune_basedir}/.cache_for_pruning
``` ```
...@@ -164,7 +164,7 @@ ls -l rest_pruner.cfg ...@@ -164,7 +164,7 @@ ls -l rest_pruner.cfg
```txt ```txt
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
--------========###| RESTIC REST PRUNER :: v0.3 |###=======-------- --------========###| RESTIC REST PRUNER :: v0.4 |###=======--------
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Pruner for restic rest server with append only option. Pruner for restic rest server with append only option.
......
...@@ -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 %-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
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:
......