@@ -61,6 +61,9 @@ func (b *Backuper) getTableListByPatternLocal(ctx context.Context, metadataPath
6161 return nil , nil , err
6262 }
6363 }
64+ // https://github.com/Altinity/clickhouse-backup/issues/1091
65+ replacer := strings .NewReplacer (`/` , "_" , `\` , "_" )
66+
6467 if err := filepath .Walk (metadataPath , func (filePath string , info os.FileInfo , err error ) error {
6568 if err != nil {
6669 return err
@@ -84,7 +87,7 @@ func (b *Backuper) getTableListByPatternLocal(ctx context.Context, metadataPath
8487 }
8588 for _ , pattern := range tablePatterns {
8689 // https://github.com/Altinity/clickhouse-backup/issues/1091
87- if matched , _ := filepath .Match (strings .Trim (pattern , " \t \r \n " ), strings .Replace (tableName , "/" , "_" , - 1 )); ! matched {
90+ if matched , _ := filepath .Match (replacer . Replace ( strings .Trim (pattern , " \t \r \n " )), replacer .Replace (tableName )); ! matched {
8891 continue
8992 }
9093 data , err := os .ReadFile (filePath )
@@ -233,6 +236,9 @@ func prepareTableMetadataFromSQL(data []byte, metadataPath string, names []strin
233236
234237func (b * Backuper ) enrichTablePatternsByInnerDependencies (metadataPath string , tablePatterns []string ) ([]string , error ) {
235238 innerTablePatterns := make ([]string , 0 )
239+ // https://github.com/Altinity/clickhouse-backup/issues/1091
240+ replacer := strings .NewReplacer ("/" , "_" , `\` , "_" )
241+
236242 if err := filepath .Walk (metadataPath , func (filePath string , info os.FileInfo , err error ) error {
237243 if err != nil {
238244 return err
@@ -246,7 +252,7 @@ func (b *Backuper) enrichTablePatternsByInnerDependencies(metadataPath string, t
246252 }
247253 for _ , pattern := range tablePatterns {
248254 // https://github.com/Altinity/clickhouse-backup/issues/1091
249- if matched , _ := filepath .Match (strings .Trim (pattern , " \t \r \n " ), strings .Replace (tableName , "/" , "_" , - 1 )); ! matched {
255+ if matched , _ := filepath .Match (replacer . Replace ( strings .Trim (pattern , " \t \r \n " )), replacer .Replace (tableName )); ! matched {
250256 continue
251257 }
252258 data , err := os .ReadFile (filePath )
@@ -493,6 +499,8 @@ func getTableListByPatternRemote(ctx context.Context, b *Backuper, remoteBackupM
493499 tablePatterns = strings .Split (tablePattern , "," )
494500 }
495501 metadataPath := path .Join (remoteBackupMetadata .BackupName , "metadata" )
502+ // https://github.com/Altinity/clickhouse-backup/issues/1091
503+ replacer := strings .NewReplacer (`/` , "_" , `\` , "_" )
496504 for _ , t := range remoteBackupMetadata .Tables {
497505 if IsInformationSchema (t .Database ) {
498506 continue
@@ -508,7 +516,7 @@ func getTableListByPatternRemote(ctx context.Context, b *Backuper, remoteBackupM
508516 return nil , ctx .Err ()
509517 default :
510518 // https://github.com/Altinity/clickhouse-backup/issues/1091
511- if matched , _ := filepath .Match (strings .Trim (pattern , " \t \r \n " ), strings .Replace (tableName , "/" , "_" , - 1 )); ! matched {
519+ if matched , _ := filepath .Match (replacer . Replace ( strings .Trim (pattern , " \t \r \n " )), replacer .Replace (tableName )); ! matched {
512520 continue
513521 }
514522 tmReader , err := b .dst .GetFileReader (ctx , path .Join (metadataPath , common .TablePathEncode (t .Database ), fmt .Sprintf ("%s.json" , common .TablePathEncode (t .Table ))))
@@ -580,11 +588,14 @@ func parseTablePatternForDownload(tables []metadata.TableTitle, tablePattern str
580588 tablePatterns = strings .Split (tablePattern , "," )
581589 }
582590 var result []metadata.TableTitle
591+ // https://github.com/Altinity/clickhouse-backup/issues/1091
592+ replacer := strings .NewReplacer ("/" , "_" , `\` , "_" )
593+
583594 for _ , t := range tables {
584595 for _ , pattern := range tablePatterns {
585596 tableName := fmt .Sprintf ("%s.%s" , t .Database , t .Table )
586597 // https://github.com/Altinity/clickhouse-backup/issues/1091
587- if matched , _ := filepath .Match (strings .Trim (pattern , " \t \r \n " ), strings .Replace (tableName , "/" , "_" , - 1 )); matched {
598+ if matched , _ := filepath .Match (replacer . Replace ( strings .Trim (pattern , " \t \r \n " )), replacer .Replace (tableName )); matched {
588599 result = append (result , t )
589600 break
590601 }
0 commit comments