From 2fb2ab94189643bedabcef1b585671da5a01832e Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Sat, 26 Nov 2022 14:45:44 +0100 Subject: [PATCH] tweak plc.d/db so that clean-dump works better, and can take an optional number of days --- plc.d/db | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plc.d/db b/plc.d/db index d3af6da..ccf9bf6 100755 --- a/plc.d/db +++ b/plc.d/db @@ -139,8 +139,10 @@ function dump_drupal_db() { } # Clean up old backups -function clean_dumps() { - find /var/lib/pgsql/backups '(' -name "$PLC_DB_NAME.*.sql" -o -name "drupal.*.sql" ')' -a -atime +15 | xargs rm -f +function clean_dump() { + local days="$1"; shift + [[ -z "$days" ]] && days=15 + find /var/lib/pgsql/backups '(' -name "${PLC_DB_NAME}*.sql" -o -name "drupal*.sql" ')' -a -mtime +$days | xargs rm -f check } @@ -210,8 +212,8 @@ restore) clean-dump) MESSAGE=$"Cleaning old database dumps" dialog "$MESSAGE" - - clean_dumps + # clean_dump has a builtin default, so no problem + clean_dump $2 result "$MESSAGE" ;; -- 2.43.0