-// BackupReader checks cancellation between reads of an archive or file.
-type BackupReader struct {
- ctx context.Context
- reader io.Reader
-}
-
-func (r BackupReader) Read(data []byte) (int, error) {
- if r.ctx.Err() != nil {
- return 0, r.ctx.Err()
- }
-
- count, err := r.reader.Read(data)
- if err != nil {
- return count, fmt.Errorf("read backup data: %w", err)
- }
-
- return count, nil
-}
-
-// backupCopyFile copies the size fixed at the snapshot of path. Growth after
-// that point is not part of the copy, and a shorter file is an error.
-func backupCopyFile(ctx context.Context, out io.Writer, path string, size int64) (err error) {
- file, err := os.Open(path)
- if err != nil {
- return fmt.Errorf("open backup file: %w", err)
+// backupExcluded keeps runtime locks, sockets, probe files, and import copies
+// out of the snapshot.
+func backupExcluded(name string) bool {
+ first, _, _ := strings.Cut(filepath.ToSlash(name), "/")
+ if first == socketFileName || first == tokenLockFileName || first == "probe" || strings.HasPrefix(first, "agent-backup-") {
+ return true