2

I've read the manpage for rsync and I don't believe this capability exists, but I wanted to confirm with someone who has extensive experience with rsync to make sure I'm not missing something (I'm on the initial setup of rsync).

Here is the situation: I two servers (A and B). I am going to setup a cron job that moves files from a directory on A to a directory on B. I have that working as expected. However, once those files are synced to directory B, I am going to moving those files to multiple other directories after renaming them.

From what I understand, rsync determines what to sync by comparing source and destination directories (timestamps, sizes, etc.). Are there any flags to use with rsync where it somehow uses a log of synced files so it knows that it already synced that file, even if it isn't there on the destination anymore?

I have an inclination this is not within rsync capabilities, but I wanted to ask. Thank you!

EDIT: I know somewhere in the manpage it specifies that you output runs to log file. Could that be referenced somehow?

  • 2
    Make hardinks instead of moving files. – Ipor Sircer Sep 1 '18 at 20:43
  • Would you mind expanding on that. I'm not sure how that would achieve what I want. – William Sep 1 '18 at 21:03
  • 1
    Instead of mving the file from B, you would instead create an additional link in the new location. The original name in directory B prevents rsync from sending it again. The hard link in the new directory means that no additional space on disk is required. – BowlOfRed Sep 2 '18 at 4:58
  • Hard links work within the same partition, but not from one partition to another one, and not for directories. It might work with symbolic links where hard links won't work (depending on how you intend to use the transferred files). – sudodus Sep 2 '18 at 5:03
  • I considered using hard links but it doesn't seem quite right for my situation. My initial rsync task will be copying files into a directory and then I will be renaming that file from a SMB mounted network drive but leaving it in the same directory. I don't want to have to renaming files from the command line. – William Sep 14 '18 at 1:57
0

It seems like a lot of work, but you could potentially:

  • Set the log format to just show the filename of copied files
  • Capture and merge that log to have a list of successfully copied files
  • Fire the next rsync with --exclude-from=FILE to exclude those from the run

As written, there's no mechanism for the list of exclusions to ever be trimmed. It would grow without bound (probably slowing things down), unless you have a way of identifying ones that are safe to remove.

  • Thanks for the thought. This is a bit beyond my skills although it sounds like it should work. – William Sep 14 '18 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.