Bugzilla – Attachment 158533 Details for
Bug 30627
koha-run-backups delete the backup files after finished its job without caring days option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30627: Verify --days parameter and use find command to select old backups for deletion
Bug-30627-Verify---days-parameter-and-use-find-com.patch (text/plain), 3.16 KB, created by
Andreas Jonsson
on 2023-11-06 14:34:59 UTC
(
hide
)
Description:
Bug 30627: Verify --days parameter and use find command to select old backups for deletion
Filename:
MIME Type:
Creator:
Andreas Jonsson
Created:
2023-11-06 14:34:59 UTC
Size:
3.16 KB
patch
obsolete
>From 937243066d9c17cd2e4b6a0e8002ec66f253c49c Mon Sep 17 00:00:00 2001 >From: Andreas Jonsson <andreas.jonsson@kreablo.se> >Date: Mon, 6 Nov 2023 15:18:42 +0100 >Subject: [PATCH] Bug 30627: Verify --days parameter and use find command to > select old backups for deletion > >Test plan > >* Create some old fake backups: > >backuproot=/var/spool/koha >instance=kohadev > >backupdir="$backuproot"/"$instance" > >for i in 1 2 3 4 ; do > for j in sql tar xxx ; do > file="$backupdir"/"$instance"-$(date -I -d "- $i day").${j}.gz > if ! test -e "$file" ; then > touch -t "$(date +%Y%m%d%H%M -d "- $i day")" "$file" > fi > done >done > >* Verify that --days parameter is validated > >sudo koha-run-backups --days 0 >sudo koha-run-backups --days foo > >* Run backup > >sudo koha-run-backups --days 3 > >* Verify that backups from 3 days have been preserved and older backups have been deleted >* Verify that filenames that do not match the pattern (the .xxx.gz files) are preserved >--- > debian/scripts/koha-run-backups | 49 ++++++++++----------------------- > 1 file changed, 14 insertions(+), 35 deletions(-) > >diff --git a/debian/scripts/koha-run-backups b/debian/scripts/koha-run-backups >index 1433c06ba1..a9223844fe 100755 >--- a/debian/scripts/koha-run-backups >+++ b/debian/scripts/koha-run-backups >@@ -60,44 +60,23 @@ while true ; do > esac > done > >+if ! test $days -gt 0 ; then >+ echo "Parameter --days must be an integer greater than 0" >+ exit 1 >+fi >+ > for name in $(koha-list --enabled | grep -Fxv demo) > do >- koha-dump ${exclude_indexes} "$name" > /dev/null >- if [ -z "$dirname" ]; then >- backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' /etc/koha/sites/$name/koha-conf.xml )"; >- else >- backupdir="$dirname/$name"; >- fi >+ if koha-dump ${exclude_indexes} "$name" > /dev/null; then >+ # Only delete old backups if dump script return success. > >- # Remove old dump files. >- # FIXME: This could probably be replaced by one line of perl. >- ls "$backupdir/" | >- sed "s:^$name-\([0-9-]*\)\.\(sql\|tar\)\.gz$:\1:" | >- sort -u | >- tac | >- sed "1,${days}d" | >- tac | >- while read date >- do >- tardump="$backupdir/$name-$date.tar.gz" >- sqldump="$backupdir/$name-$date.sql.gz" >- if [ -e "$tardump" ] && [ -e "$sqldump" ] >- then >- rm "$tardump" >- rm "$sqldump" >- elif [ -e "$tardump" ] || [ -e "$sqldump" ] >- then >- echo "Only one of a pair exists! Not removing it." >- for x in "$tardump" "$sqldump" >- do >- if [ -e "$x" ] >- then >- echo "Exists : $x" >- else >- echo "Does not exist: $x" >- fi >- done >+ if [ -z "$dirname" ]; then >+ backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' /etc/koha/sites/$name/koha-conf.xml )"; >+ else >+ backupdir="$dirname/$name"; > fi >- done >+ >+ find $backupdir -maxdepth 1 \( -mtime +$days -or -mtime $days \) -name $name-'[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].???'.gz \( -name \*.sql.gz -or -name \*.tar.gz \) -print0 | xargs -0 -r rm >+ fi > done > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30627
:
158533
|
159931
|
161494