Safe to add files to directory during backup?

Hi there,
I run a daily backup of my files at 3 am. Because I have pretty bad internet upload speeds, the backup can take a long time, depending on how many files I added. Sometimes even well into the day.
The directories that I backup are very much “write once, read many”, files rarely change, and I make sure not to do any changes while a backup is running.
Would it be OK to add files while a backup is running? It wouldn’t have to pick them up in the current run (though that would be cool), I’m just wondering whether it’s safe to do.
Thank you!

Hi @estebanmills and welcome to the restic community! :slight_smile:

Yes, it is safe to add files to a folder that is currently being backed up. As you suggested, it might not be in the backup “run” that is currently doing a backup, but it will be in the next.

IIRC There might be a small window when restic walks the filesystem to get all files and folders for the backup, where you can “sneak” in a new file that will then be picked up for the currently running backup. This would probably only work for larger datasets where restic has to walk large structures where the time it takes restic to do that is quiet long.
But also I remember there was tons of work to speed up things in the backup command and it might not be possible anymore.

I hope this helps as a general information :slight_smile:


Awesome, thank you for confirming.

Reading a filesystem is inherently racy. If you modify a file while restic reads it, the backup will contain a garbled copy of the file. This will be fixed by the next backup run, but it is something to look out for. In particular databases, will not react gracefully in such a case. The only way to avoid this is some form of filesystem snapshot (or stopping all applications modifying files). But for slowly changing data, just running backup is usually good enough.

1 Like

I knew when I wrote it that there would be a caveat - thanks for clearing that up :slight_smile: