From 6926bad545418fec01be7c4569e40efe21c14ed3 Mon Sep 17 00:00:00 2001 From: Ali Afsharzadeh Date: Sun, 10 May 2026 11:27:41 +0330 Subject: [PATCH] Fix backup retention logic issues for rsync --- test/integration/rsync/upload.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/rsync/upload.sh b/test/integration/rsync/upload.sh index 64645bb7b..e6677ef23 100755 --- a/test/integration/rsync/upload.sh +++ b/test/integration/rsync/upload.sh @@ -20,10 +20,10 @@ done if [[ "" != "${BACKUP_KEEP_TO_REMOTE}" && "0" != "${BACKUP_KEEP_TO_REMOTE}" ]]; then BACKUP_LIST=$(${CUR_DIR}/list.sh) - BACKUP_COUNT=$(echo $BACKUP_LIST | wc -l) - if [[ $BACKUP_COUNT > $BACKUP_KEEP_TO_REMOTE ]]; then - let BACKUP_TO_NEED_DELETE=$BACKUP_COUNT - $BACKUP_KEEP_TO_REMOTE - BACKUP_TO_NEED_DELETE=$(echo $BACKUP_LIST | clickhouse-local --input-format="JSONEachRow" -q "SELECT backup_name FROM table ORDER BY creation_date LIMIT ${BACKUP_TO_NEED_DELETE}") + BACKUP_COUNT=$(echo "$BACKUP_LIST" | wc -l) + if [[ $BACKUP_COUNT -gt $BACKUP_KEEP_TO_REMOTE ]]; then + BACKUP_TO_NEED_DELETE=$((BACKUP_COUNT - BACKUP_KEEP_TO_REMOTE)) + BACKUP_TO_NEED_DELETE=$(echo "$BACKUP_LIST" | clickhouse-local --input-format="JSONEachRow" -q "SELECT backup_name FROM table ORDER BY creation_date LIMIT ${BACKUP_TO_NEED_DELETE}") for backup_name in $BACKUP_TO_NEED_DELETE; do ${CUR_DIR}/delete.sh "${backup_name}" done