diff --git a/Examples.md b/Examples.md index 85f03662..395c5472 100644 --- a/Examples.md +++ b/Examples.md @@ -425,15 +425,14 @@ spec: CLICKHOUSE_SCHEMA_RESTORE_SERVICES=$(echo $CLICKHOUSE_SCHEMA_RESTORE_SERVICES | tr "," " "); CLICKHOUSE_DATA_RESTORE_SERVICES=$(echo $CLICKHOUSE_DATA_RESTORE_SERVICES | tr "," " "); for SERVER in $CLICKHOUSE_SCHEMA_RESTORE_SERVICES; do - LATEST_BACKUP_NAME=$(clickhouse-client -q "SELECT name FROM system.backup_list WHERE location='remote' AND desc NOT LIKE 'broken%' AND name LIKE '%${SERVER}%' ORDER BY created DESC LIMIT 1 FORMAT TabSeparatedRaw" --host="$SERVER" --port="$CLICKHOUSE_PORT" --user="$BACKUP_USER" $BACKUP_PASSWORD); + SHARDED_PREFIX=${SERVER%-*} + LATEST_BACKUP_NAME=$(clickhouse-client -q "SELECT name FROM system.backup_list WHERE location='remote' AND desc NOT LIKE 'broken%' AND name LIKE '%${SHARDED_PREFIX}%' ORDER BY created DESC LIMIT 1 FORMAT TabSeparatedRaw" --host="$SERVER" --port="$CLICKHOUSE_PORT" --user="$BACKUP_USER" $BACKUP_PASSWORD); if [[ "" == "$LATEST_BACKUP_NAME" ]]; then echo "Remote backup not found for $SERVER"; exit 1; fi; BACKUP_NAMES[$SERVER]="$LATEST_BACKUP_NAME"; clickhouse-client -mn --echo -q "INSERT INTO system.backup_actions(command) VALUES('restore_remote --schema --rm ${BACKUP_NAMES[$SERVER]}')" --host="$SERVER" --port="$CLICKHOUSE_PORT" --user="$BACKUP_USER" $BACKUP_PASSWORD; - done; - for SERVER in $CLICKHOUSE_SCHEMA_RESTORE_SERVICES; do while [[ "in progress" == $(clickhouse-client -mn -q "SELECT status FROM system.backup_actions WHERE command='restore_remote --schema --rm ${BACKUP_NAMES[$SERVER]}' ORDER BY start DESC LIMIT 1 FORMAT TabSeparatedRaw" --host="$SERVER" --port="$CLICKHOUSE_PORT" --user="$BACKUP_USER" $BACKUP_PASSWORD) ]]; do echo "still in progress ${BACKUP_NAMES[$SERVER]} on $SERVER"; sleep 1; diff --git a/ReadMe.md b/ReadMe.md index 1336ab59..69dc8a10 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -123,6 +123,7 @@ general: # RESTORE_TABLE_MAPPING, restore rules from backup tables to target tables, which is useful when changing destination tables. # The format for this env variable is "src_table1:target_table1,src_table2:target_table2". For YAML please continue using map syntax restore_table_mapping: {} + retries_on_failure: 3 # RETRIES_ON_FAILURE, how many times to retry after a failure during upload or download retries_pause: 30s # RETRIES_PAUSE, duration time to pause after each download or upload failure