k0lter / autopostgresqlbackup

Automated tool to make periodic backups of PostgreSQL databases
52 stars 17 forks source link

Correct cleanup() tail filter #19

Closed jhowe-uw closed 10 months ago

jhowe-uw commented 1 year ago

tail +${count} generates an error on RHEL 6-8 systems. Make intent explicit with "-n +${count}"

+++ b/files/usr/local/sbin/autopostgresqlbackup
@@ -475,7 +475,7 @@ cleanup() {
         sed -r 's/^.+([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}h[0-9]{2}m).*$/\1 \0/'
         sort -r | \
         sed -r -n 's/\S+ //p' | \
-        tail "+${count}" | \
+        tail "-n +${count}" | \
         xargs -L1 rm -fv | \
         while IFS= read -r line ; do
             log_info "${line}"
TheFlipside commented 1 year ago

@jhowe-uw thanks so much for this fix, it was bugging me for the longest time in my report emails.

@k0lter fyi, with the current default the report contains multiple instances of "tail: cannot open '+14' for reading: No such file or directory". It would be nice if this change could be applied to main

k0lter commented 1 year ago

@jhowe-uw This is fixed with my last commit. Thanks for your feedback.

k0lter commented 10 months ago

I'm closing this bug as it is already solved.