53

I am doing a backup of my desktop to a remote machine. I'm basically doing rsync -a ~ example.com:backup/ However there are loads of large files, e.g. wikipedia dumps etc. Most of the files I care a lot about a small, such as firefox cookie files, or .bashrc. Is there some invocation to rsync that will exclude files that are over a certain size? That way I could copy all files that are less than 10MB first, then do all files. That way I can do a fast backup of the most important files, then a longer backup of everything else.

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
  • Yep, all those `.iso` images or `.mov` screen recordings not only take up valuable space but valuable time. I'm in a race against time to backup my computer before handing it over to the Apple iRepair people who clobber your data even when it's not necessary. – Sridhar Sarnobat May 02 '18 at 00:31
  • `Docker.raw` is another! – Sridhar Sarnobat Jun 02 '22 at 20:14

1 Answers1

87

There is a max-size option:

--max-size=SIZE         don't transfer any file larger than SIZE

So:

# rsync -rv --max-size=1.5m root@tss01:/tmp/dm

Will send only files less than 1.5m.

Regarding sizes from man: The suffixes are as follows: "K" (or "KiB") is a kibibyte (1024), "M" (or "MiB") is a mebibyte (1024*1024), and "G" (or "GiB") is a gibibyte (1024*1024*1024). If you want the multiplier to be 1000 instead of 1024, use "KB", "MB", or "GB". (Note: lower-case is also accepted for all values.) Finally, if the suffix ends in either "+1" or "-1", the value will be offset by one byte in the indicated direction*

gm3dmo
  • 9,632
  • 1
  • 40
  • 35
  • 6
    Note however, that --max-size is not a real "exclude", from the man-page: This option is a transfer rule, not an exclude, so it doesn't affect the data that goes into the file-lists, and thus it doesn't affect deletions. It just limits the files that the receiver requests to be transferred. – schlicht Oct 02 '14 at 14:01
  • @schlicht Valuable information. So how to auto-delete files that were below the `max-size` limit previously and now surpassed such limit when using the `--delete` flag? Is there a smarter way than simply using the [`find` method](https://superuser.com/a/644274/322536) afterwards? – Martin Braun Aug 08 '22 at 05:30