bad performance on larger repositories with nonchanged files
I have a small repository with some testdata:
Initial Backup: Duration: 57.15 seconds Backup without any change: Duration: 3.09 seconds
Total Archive Size ~1GB ~500 files
I also have a rather big archive: Command line: borg create -s -p -x --chunker-params 19,23,21,4095 --show-rc Number of files: 72092 Original size Compressed size Deduplicated size This archive: 706.77 GB 706.79 GB 33.14 MB All archives: 2.56 TB 2.56 TB 701.77 GB
As you can see almost no data has changed but it took 6 hours to do the backup. My guess its almost as fast as a full backup. I was looking at iotop and it seemed to have read all the files again.
If we use the 3 sec it took for 1 GB the backup should have taken like 35 minutes or even less.
I used the chunk setting above because most of the data are media files so there wont be good a dedup anyways.
As far as i understand borg it uses a file cache to do a fast rsync like detection if a file even has changed and if not skips it?
So I would expect it to just read the metadata for 72.000 files compares them and would skip almost all of them ?
Yes, borg usually does not read all files again, but compares each file's mtime, inode, size against what it has in the "file cache".
If it matches, it skips the file because it has not changed. If there is a mismatch, it reads and chunks the file again.
Considering that, the following scenarios might lead to what you have seen:
- all your files were touched (mtime) or otherwise modified
- you did not have a files cache (e.g. because you deleted it)
- you explicitly told borg to not use the files-cache (there is a commandline option)
How long a backup with usage of the files cache and with mostly unmodified files takes depends mostly on the amount of files.
Can you reproduce the effect?
all your files were touched (mtime) or otherwise modified
I´m pretty sure i dont modify them looking at a sample (stat) it was modified a long time ago: Größe: 9235927 Blöcke: 18432 EA Block: 16384 Normale Datei Gerät: 2ch/44d Inode: 10277895 Verknüpfungen: 1 Zugriff: (0665/-rw-rw-r-x) Uid: ( 1000/ xxx) Gid: ( 1002/xxx) Zugriff : 2016-02-02 08:42:00.759712800 +0100 Modifiziert: 2014-09-22 17:29:12.948000000 +0200 Geändert : 2014-09-22 17:29:12.948000000 +0200 Geburt : -
you did not have a files cache (e.g. because you deleted it)
I did not delete anything at least not on purpose.
you explicitly told borg to not use the files-cache (there is a commandline option)
I did not use the commandline option. As posted above my command is: borg create -s -p -x --chunker-params 19,23,21,4095 --show-rc
I dont know if this is related but the source is a local samba mount from https://www.greyhole.net/ Although rsync and rdiff-backup dont seem to have a problem looking at the mtime.
if it is a samba mount, maybe check if the inode number stays the same if you umount and mount again.
ls -i
Also, you need to make sure that the full pathname of the files you back up stays the same. So, do not mount sometimes at /mnt/foo and other times at /mnt/bar.
The samba mount was always mounted between the backups if I start the backup again now and compare the conky diskio graph vs the progress outputted by borg it seem like its reading the whole files again. Also inode Number stays the same.
dstat -tdD md2 60
----system---- --dsk/md2--
time | read writ
02-02 16:33:47| 902k 57k
02-02 16:34:24| 34M 0
ls -l ~/.cache/borg/REPOID # get the repo id from the repository/config file
ls -la ~/.cache/borg/239c26aeffe9b91af7c8860f546627e8668965eab77678090cb9494fb4d126b3
insgesamt 36704
drwx------ 4 xx 4096 Feb 2 16:57 .
drwx------ 12 xx 4096 Feb 2 10:35 ..
-rw------- 1 xx19608574 Feb 2 16:55 chunks
drwx------ 2 xx 4096 Feb 2 00:08 chunks.archive.d
-rw------- 1 xx 318 Feb 2 16:55 config
-rw------- 1 xx17941631 Feb 2 16:55 files
-rw------- 1 xx 17 Feb 2 16:57 lock.roster
-rw------- 1 xx 20 Jan 15 14:43 README
drwx------ 2 xx 4096 Feb 2 16:55 txn.active
that "files" there is the files cache, "chunks" is the chunks cache. maybe check if the files are accessible / readable by the user running borg.
btw: chunks.archives.d can grow big, see faq in case it gets too big.
yes files are readable by me and its the same user thats running the backup
this is the code used for skipping unchanged files:
def file_known_and_unchanged(self, path_hash, st):
if not (self.do_files and stat.S_ISREG(st.st_mode)):
return None
if self.files is None:
self._read_files()
entry = self.files.get(path_hash)
if not entry:
return None
entry = msgpack.unpackb(entry)
if entry[2] == st.st_size and bigint_to_int(entry[3]) == st.st_mtime_ns and entry[1] == st.st_ino:
# reset entry age
entry[0] = 0
self.files[path_hash] = msgpack.packb(entry)
return entry[4]
else:
return None
You see it checks size, mtime, inode for all regular files. The lookup is done via the path_hash (== H(full_path)). If self.do_files is False (via --no-files-cache), the mechanism is disabled.
After further testing the file cache appears to be used when backing up locally. A backed up directory of 100 GB and around 5000 files with no changed files gets backed up in less than 10 sec.
This might be related to #622 that it somehow breaks existing remote repositories.
The collection of source files is not different when using a local repo or a remote repo.
Hi fsironman,
which version do you utilise? I had exactly the same problem with version 0.29 under OSX. I came here to write a bug report, when I saw there was a 0.3 Version. I retried with that and after one long run like in v. 0.29 the following backups are fast now.
0.29 always rehashed one big file (>20GB) again and again even if it did not change. 0.30 does not.
Sadly I wrote my lengthy posting already, including all the details but hey, I am more happy it works now.
BTW, there is a FAQ item about why one might see a "modified file" even if it was not modified.
Doing a slight artifical modification to some other file immediately before the backup can be used to work around this, like touch /BACKUPTIMESTAMP.
The repository I have the issue was created with 0.29.0 was backuped a few times with 0.29.0 and twice now with 0.30.0.
I tried to reproduce the issue with 0.29.0 aswell as 0.30.0 but it did work there.
The test I´m curently doing is to fill the repository with 0.29.0 and then upgrade to 0.30.0 and backup again.
I also included the increased segment size and chunker parms because this could be an issue as well.
BTW, there is a FAQ item about why one might see a "modified file" even if it was not modified.
If I understand this right this mark every file whos mtime is in the time between backup start and end. So if i have years old mtimes it should not apply at all and also not apply to every file.
As next test i will be doing a backup with borg create -v --list one in the "broken" repository and one in the new hopefully intact one and compare them
I had the samba share mounted with noserverino which changes the inode numbers randomly after some time.
So its not a problem with borg my bad.
Question is if I would mount a windows share I would most likely face the same Problem. would it be possible to add an option not to check for the inode ?
@fsironman ah, good you found the reason.
you said 0.29 and 0.30 behaved differently - do you still uphold that? because if that were the case, it would need some investigation.
Yes, one could definitely add such an option, but then the check for unmodified files could be only with less confidence (it would just look at size and mtime). See #628.
About the "added, but unchanged file" FAQ item: it only applies to the set of files that have the latest mtime in the archive (max(mtimes of all files)), see the explanation in the FAQ. Even if that is long in the past, you never can be sure (read FAQ again and think about it).
BTW, I'ld like to remove all the discussion about that from this issue as it is unrelated. If there is a need to discuss that, we could do in another issue or on the mailing list or on IRC.
So, close this or is there anything left to do here?
I thought it behaved differently because i used a smaller dataset at first for my 0.30.0 test. When the dataset was small enough samba did not report a new inode immediately. Which made it difficult to trace.
Ah, ok, thanks for investigating these issues!