Skip to content

Commit

Permalink
fix upload / download files from projections multiple times, cause ba…
Browse files Browse the repository at this point in the history
…ckup create wrong create *.proj as separate data part, fix #622
  • Loading branch information
Slach committed Mar 30, 2023
1 parent 2bee092 commit de8f066
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ IMPROVEMENTS
- add additional server-side encryption parameters to s3 config section, fix [619](https://github.com/AlexAkulov/clickhouse-backup/issues/619)
BUG FIXES
- fix error after restart API server when .state file present in backup folder, fix [623](https://github.com/AlexAkulov/clickhouse-backup/issues/623)

- fix upload / download files from projections multiple times, cause backup create wrong create *.proj as separate data part, fix [622](https://github.com/AlexAkulov/clickhouse-backup/issues/622)

# v2.2.0
IMPROVEMENTS
Expand Down
15 changes: 10 additions & 5 deletions pkg/filesystemhelper/filesystemhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ func MoveShadow(shadowPath, backupPartsPath string, partitionsBackupMap common.E
size := int64(0)
parts := make([]metadata.Part, 0)
err := filepath.Walk(shadowPath, func(filePath string, info os.FileInfo, err error) error {
relativePath := strings.Trim(strings.TrimPrefix(filePath, shadowPath), "/")
pathParts := strings.SplitN(relativePath, "/", 4)
// possible relative path
// store / 1f9 / 1f9dc899-0de9-41f8-b95c-26c1f0d67d93 / 20181023_2_2_0 / checksums.txt
// store / 1f9 / 1f9dc899-0de9-41f8-b95c-26c1f0d67d93 / 20181023_2_2_0 / x.proj / checksums.txt
// data / database / table / 20181023_2_2_0 / checksums.txt
// data / database / table / 20181023_2_2_0 / x.proj / checksums.txt
relativePath := strings.Trim(strings.TrimPrefix(filePath, shadowPath), "/")
pathParts := strings.SplitN(relativePath, "/", 4)
if len(pathParts) != 4 {
return nil
}
Expand All @@ -207,9 +210,11 @@ func MoveShadow(shadowPath, backupPartsPath string, partitionsBackupMap common.E
}
dstFilePath := filepath.Join(backupPartsPath, pathParts[3])
if info.IsDir() {
parts = append(parts, metadata.Part{
Name: pathParts[3],
})
if !strings.HasSuffix(pathParts[3], ".proj") {
parts = append(parts, metadata.Part{
Name: pathParts[3],
})
}
return os.MkdirAll(dstFilePath, 0750)
}
if !info.Mode().IsRegular() {
Expand Down

0 comments on commit de8f066

Please sign in to comment.