Skip to content

Commit

Permalink
split tmutil call args across two batched calls
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Sep 20, 2024
1 parent 4049f05 commit 6ad0a36
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ee/agent/timemachine/timemachine_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ func AddExclusions(ctx context.Context, k types.Knapsack) {
launcher.pid
*/

exclusionPatterns := []string{
exclusionPatternsFirstBatch := []string{
"*.json",
"*.json.gz",
"*.db",
}

addExclusionsFromPathPatterns(ctx, k, exclusionPatternsFirstBatch)

// Attempting to run this with a single tmutil call we see a lot of tmutil failures logged with error "argument list too long".
// To avoid this we run in two separate batches, attempting to cut the post-glob argument list roughly in half
exclusionPatternsSecondBatch := []string{
"*.sqlite",
"desktop_*",
"*.pid",
Expand All @@ -45,6 +52,10 @@ func AddExclusions(ctx context.Context, k types.Knapsack) {
"osquery*",
}

addExclusionsFromPathPatterns(ctx, k, exclusionPatternsSecondBatch)
}

func addExclusionsFromPathPatterns(ctx context.Context, k types.Knapsack, exclusionPatterns []string) {
var exclusionPaths []string
for _, pattern := range exclusionPatterns {
matches, err := filepath.Glob(filepath.Join(k.RootDirectory(), pattern))
Expand Down

0 comments on commit 6ad0a36

Please sign in to comment.