diff --git a/pkg/backup/local.go b/pkg/backup/local.go index fe55ae2..f40a2f7 100644 --- a/pkg/backup/local.go +++ b/pkg/backup/local.go @@ -87,7 +87,7 @@ func dump(plan config.Plan, tmpPath string, ts time.Time) (string, string, error func getDumpedDocMap(output string) map[string]string { result := map[string]string{} - dbDocCapRegex := `done dumping\s\w*\.(\S*)\s\((\d*).document` + dbDocCapRegex := `done dumping\s[\w,-]*\.(\S*)\s\((\d*).document` reg := regexp.MustCompile(dbDocCapRegex) lines := strings.Split(output, "\n") diff --git a/pkg/backup/local_test.go b/pkg/backup/local_test.go index 97e7a60..7f2a95e 100644 --- a/pkg/backup/local_test.go +++ b/pkg/backup/local_test.go @@ -41,3 +41,22 @@ func Test_getDumpedDocMap(t *testing.T) { // test "." in the collection name assert.Equal(t, strconv.Itoa(1), result["Contents.Published_Count"]) } + +func Test_getDumpedDocMapWithDash(t *testing.T) { + dumpOutput := []byte(`2022-09-12T23:00:00.102+0000 writing db-collection.Contents_Published to archive '/tmp/content-1663023600.gz' + 2022-09-12T23:00:00.102+0000 writing db-collection.Contents_Count to archive '/tmp/content-1663023600.gz' + 2022-09-12T23:00:00.102+0000 writing db-collection.Contents_Published_Count to archive '/tmp/content-1663023600.gz' + 2022-09-12T23:00:00.116+0000 writing db-collection.Contents_All to archive '/tmp/content-1663023600.gz' + 2022-09-12T23:00:00.128+0000 done dumping db-collection.Contents.Published_Count (1 document) + 2022-09-12T23:00:00.140+0000 done dumping db-collection.Contents_Count (3 documents) + 2022-09-12T23:00:00.565+0000 done dumping db-collection.Contents_Published (7415 documents) + 2022-09-12T23:00:03.010+0000 [####################....] db-collection.Contents_All 84357/99427 (84.8%) + 2022-09-12T23:00:03.171+0000 [########################] db-collection.Contents_All 99427/99427 (100.0%) + 2022-09-12T23:00:03.294+0000 done dumping db-collection.Contents_All (99427 documents) + `) + result := getDumpedDocMap(string(dumpOutput)) + assert.Len(t, result, 4) + assert.Equal(t, strconv.Itoa(7415), result["Contents_Published"]) + // test "." in the collection name + assert.Equal(t, strconv.Itoa(1), result["Contents.Published_Count"]) +}