Skip to content

Commit 044ca6b

Browse files
authored
Merge pull request #1654 from Altinity/issue_1653_regular_download_backup_disk
download: skip chown of embedded_backup_disk for regular backups
2 parents 0594ace + 6183c58 commit 044ca6b

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎pkg/backup/download.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ func (b *Backuper) downloadEpilogue(ctx context.Context, backupName string, remo
425425
return err
426426
}
427427
for _, disk := range disks {
428-
if disk.IsBackup {
428+
// a regular backup writes nothing to embedded_backup_disk, https://github.com/Altinity/clickhouse-backup/issues/1653
429+
if b.isEmbedded && disk.IsBackup {
429430
if err = filesystemhelper.Chown(path.Join(disk.Path, backupName), b.ch, disks, true); err != nil {
430431
return errors.Wrap(err, "Chown backup disk")
431432
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//go:build integration
2+
3+
package main
4+
5+
import (
6+
"os"
7+
"testing"
8+
"time"
9+
)
10+
11+
// https://github.com/Altinity/clickhouse-backup/issues/1653
12+
func TestDownloadRegularBackupWithEmbeddedBackupDisk(t *testing.T) {
13+
if compareVersion(os.Getenv("CLICKHOUSE_VERSION"), "22.6") < 0 {
14+
t.Skip("backups_s3 disk is configured for 22.6+ only")
15+
}
16+
env, r := NewTestEnvironment(t)
17+
defer env.Cleanup(t, r)
18+
env.connectWithWait(t, r, 0*time.Second, 1*time.Second, 1*time.Minute)
19+
backupName := "test_regular_embedded_disk"
20+
dbName := "test_regular_embedded_disk_db"
21+
cfg := "/etc/clickhouse-backup/config-s3.yml"
22+
embeddedEnv := "CLICKHOUSE_USE_EMBEDDED_BACKUP_RESTORE=true CLICKHOUSE_EMBEDDED_BACKUP_DISK=backups_s3 CLICKHOUSE_TIMEOUT=4h "
23+
24+
env.queryWithNoError(t, r, "CREATE DATABASE "+dbName)
25+
env.queryWithNoError(t, r, "CREATE TABLE "+dbName+".t (id UInt64) ENGINE=MergeTree() ORDER BY id")
26+
env.queryWithNoError(t, r, "INSERT INTO "+dbName+".t SELECT number FROM numbers(1000)")
27+
env.DockerExecNoError(r, "clickhouse-backup", "clickhouse-backup", "-c", cfg, "create_remote", "--tables="+dbName+".*", backupName)
28+
env.DockerExecNoError(r, "clickhouse-backup", "clickhouse-backup", "-c", cfg, "delete", "local", backupName)
29+
30+
// the backup is regular, embedded_backup_disk from config shall not be touched
31+
env.DockerExecNoError(r, "clickhouse-backup", "bash", "-ce", embeddedEnv+"clickhouse-backup -c "+cfg+" download "+backupName)
32+
env.DockerExecNoError(r, "clickhouse-backup", "bash", "-ce", embeddedEnv+"clickhouse-backup -c "+cfg+" restore --rm "+backupName)
33+
env.checkCount(r, 1, 1000, "SELECT count() FROM "+dbName+".t")
34+
35+
env.DockerExecNoError(r, "clickhouse-backup", "clickhouse-backup", "-c", cfg, "delete", "local", backupName)
36+
env.DockerExecNoError(r, "clickhouse-backup", "clickhouse-backup", "-c", cfg, "delete", "remote", backupName)
37+
r.NoError(env.dropDatabase(dbName, false))
38+
}

0 commit comments

Comments
 (0)