Skip to content

Improve --exclude-cloud-files to ignore iCloud-only files on macOS #5352

@hashier

Description

@hashier

Output of restic version

restic 0.18.0 compiled with go1.24.1 on darwin/arm64

What should restic do differently? Which functionality do you think we should add?

Improve/extend --exclude-cloud-files to also work on macOS/darwin with iCloud files.
Prior work that implemented this for windows:

What are you trying to do? What problem would this solve?

Be able to ignore iCloud files that are only stored in the cloud and not locally.
(A reason to write/learn some go code and provide something to restic)

Did restic help you today? Did it make you happy in any way?

Every day! Recently moved to a cron job (launchd agent) for restic. Had it for 3 years running manually but thought this should be automated. Now my system gets daily backups instead of just every 2 weeks when I remember to run restic.

Additional info

I wrote a small POC for this change. If no one is already working on it I would try to follow the PR that implemented this feature on Windows

PR that implements this feature

#5370

POC Code

package main

import (
	"fmt"
	"os"
	"syscall"

	"golang.org/x/sys/unix"
)

func main() {
	isCloudFile("a")
	isCloudFile("b")
}

func isCloudFile(filePath string) {
	fileInfo, _ := os.Stat(filePath)
	v, ok := fileInfo.Sys().(*syscall.Stat_t)
	if !ok {
		fmt.Println("Can't get flags of file", filePath)
	}
	const mask uint32 = unix.SF_DATALESS // 0x40000000
	if v.Flags&mask == mask {
		fmt.Println(filePath, "is cloud file")
	} else {
		fmt.Println(filePath, "is normal file")
	}
}
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions