Sometimes restic does not correctly apply the forget policy
And that might waste
- tons of space ..
- computation time during backup …
- clarity since terminal goes a bit crazy with 3000+ lines
The fix is not so easy…
forgetlist="";restic unlock;
restic snapshots|grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]"|sed 's/ +/ /g'|cut -d" " -f1-3|while read line;do
id=${line/ *};
shotdate=$(echo "$line"|cut -d" " -f2,3) ;
shotepoch=$(date -u -d "$shotdate" +%s) ;
shotagesec=$(($(date -u +%s )-$shotepoch));
echo -n "SNAP: $shotdate ( $shotagesec ) ";
[[ $shotagesec -ge $((86400*90)) ]] && { echo -n "forget $id |" ;forgetlist="$forgetlist $id" ; echo "$forgetlist" > /dev/shm/.restic_forget_list ; } ;
[[ $(echo $forgetlist|wc -w ) -ge 30 ]] && { restic forget $forgetlist |sed 's/$/|/g' |tr -d 'n' ;forgetlist="" ; } ;
echo;done;
restic forget $forgetlist |sed 's/$/|/g' |tr -d 'n' ;forgetlist="" ;time restic prune
Oh wow ..