Skip to content

Commit 535c6f7

Browse files
authored
refactor(data): exclude data.img in time machine (#58)
See: orbstack/orbstack#29 Signed-off-by: Kevin Cui <[email protected]>
1 parent d9749f1 commit 535c6f7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/utils/file.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"os"
10+
"os/exec"
1011
"path/filepath"
1112
)
1213

@@ -55,7 +56,16 @@ func CreateSparseFile(p string, size int64) error {
5556
return fmt.Errorf("truncate sparse file failed: %w", err)
5657
}
5758

58-
return file.Sync()
59+
if err := file.Sync(); err != nil {
60+
return fmt.Errorf("sync sparse file failed: %w", err)
61+
}
62+
63+
go func() {
64+
cmd := exec.Command("xattr", "-w", "com.apple.metadata:com_apple_backup_excludeItem", "com.apple.backupd", p)
65+
_ = cmd.Run()
66+
}()
67+
68+
return nil
5969
}
6070

6171
func PathExists(p string) (bool, error) {

0 commit comments

Comments
 (0)