13

Is there a way to tell rsync to skip its current file while a sync is in progress, maybe by sending it a particular signal?

I already know about ignoring based on patterns, but this would be handy to me sometimes.

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448

4 Answers4

7

I'm not familiar with such functionality, and the manual page for the current version doesn't make mention either. Short of browsing thru the source looking for "hidden features" that aren't mentioned in the manual page I think it's safe to assume that there's not any such functionality.

I agree, though, that it sounds like it could be a handy feature.

Evan Anderson
  • 141,881
  • 20
  • 196
  • 331
5

Sadly, the answer is "no", but there is a Bug Report in the rsync Bugzilla requesting this enhancement. Maybe someday...

Dean Serenevy
  • 151
  • 1
  • 2
4

I always kill rsync (control-c) and re-run with an --exclude option and possibly --delete. Since rsync leaves the destination directory partially updated, the second run should be faster because you can essentially start where you left off.

You might also look at the partial-dir option for large files.

0

The rsync feature request mentioned by @dean-serenevy has a workaround:

  1. Backup sourcefile if still needed, e.g. cp --reflink=always --preserve largefile largefile.backup
  2. Truncate the file: echo > largefile
  3. Wait for rsync to detect that something is wrong. This may take a while but rsync should at least stop writing more data to the target file. When an error is detected, rsync will try again, see that the file is a lot shorter (1 byte long, a single newline character) and update the target to match it.
  4. Restore the backup: mv largefile.backup largefile if the inode number does not matter, cat largfile.backup > largefile if the inode number must stay the same (at the cost of requiring twice the space temporarily). Also consider ownership, permissions, extended attributes, sparseness and special filesystem features such as compression and de-duplication.
  • 1
    This of course will possibly mess things up if it's a live linked file (ie has an open count by some process > 1 meaning the file is 'in use' - can use fuser(1) or lsof(8) to check ). So beware you may confuse a running process, or at least need to restart it or otherwise signal it to reread files/reopen logfiles (a usual candidate for skipping without cancelling rsync). – math Jan 08 '23 at 15:23