Skip to content

Restic uses mtime to detect file changes, which can miss changes. #2179

@d3zd3z

Description

@d3zd3z

Output of restic version

restic 0.9.4 compiled with go1.11.4 on linux/amd64

How did you run restic exactly?

see below for the exact commands I used. Repo is local, and no other arguments are given to the backup command.

What backend/server/service did you use to store the repository?

Local.

Expected behavior

Follow the script, and expect restic to backup the given file after it has been modified.

Actual behavior

"Files: 0 new, 0 changed, 4 unmodified"

Steps to reproduce the behavior

echo "Hello world" > a.txt
echo "hELLO WORLD" > b.txt
touch stamp
cat a.txt > hello.txt
touch -r stamp hello.txt
restic -r /tmp/test-repo -p a.txt init
restic -r /tmp/test-repo -p a.txt backup .
sleep 10
cat b.txt > hello.txt
touch -r stamp hello.txt
restic -r /tmp/test-repo -p a.txt backup .

Do you have any idea what may have caused this?

mtime should not be used to determine if a file needs to be backed up, ctime should be used. Worst case with ctime is that restic will needlessly read/hash the file to determine if it has changed. By using mtime it can skip backing up a file.

I have seen the Debian package manager, specifically, replace a file with a different file, and put the mtime back to the same value.

If I add -f to the backup command, the file will indeed be backed up.

Do you have an idea how to solve the issue?

Ideally, use ctime. Maybe use both, or provide an option, but ctime is really what should be used. It would probably have to revert to mtime on a filesystem that doesn't have a ctime.

Did restic help you or made you happy in any way?

It makes me happy that it otherwise seems to reliably back up my files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions