Skip to main content
added 349 characters in body
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

In two steps (for simplicity, even though these steps can definitely be combined).

First transfer "small" files:

find /source/path -type f -size -100M -print0 | rsync -av -0 --files-from=- /source/path user@server:/destination/ 

Then transfer "big" files whose filenames match pattern:

find /source/path -type f -size +99M -name 'pattern' -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

This is, however, untested.

-print0 in GNU find (and others) will print the found names with a nul delimiter, and -0 with rsync will make --files-from- interpret this standard input stream in that particular way.

The file paths read with --files-from should be relative to the specified source, that's why I use / as the source in rsync (I'm assuming /source/path in find is an absolute path).


Combined variation (also not tested):

find /source/path -type f \ \( -size -100M -o -name 'pattern' \) -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

With more than one allowable pattern string for "big" files:

find /source/path -type f \ \( -size -100M -o -name 'pattern1' -o -name 'pattern2' -o -name 'pattern3' \) -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

Each pattern may be something like *.mp4 or whatever file extensions you use. Note that these needs to be quoted, as in -name '*.mp4'.

In two steps (for simplicity, even though these steps can definitely be combined).

First transfer "small" files:

find /source/path -type f -size -100M -print0 | rsync -av -0 --files-from=- /source/path user@server:/destination/ 

Then transfer "big" files whose filenames match pattern:

find /source/path -type f -size +99M -name 'pattern' -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

This is, however, untested.

-print0 in GNU find (and others) will print the found names with a nul delimiter, and -0 with rsync will make --files-from- interpret this standard input stream in that particular way.

The file paths read with --files-from should be relative to the specified source, that's why I use / as the source in rsync (I'm assuming /source/path in find is an absolute path).

In two steps (for simplicity, even though these steps can definitely be combined).

First transfer "small" files:

find /source/path -type f -size -100M -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

Then transfer "big" files whose filenames match pattern:

find /source/path -type f -size +99M -name 'pattern' -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

This is, however, untested.

-print0 in GNU find (and others) will print the found names with a nul delimiter, and -0 with rsync will make --files-from- interpret this standard input stream in that particular way.

The file paths read with --files-from should be relative to the specified source, that's why I use / as the source in rsync (I'm assuming /source/path in find is an absolute path).


Combined variation (also not tested):

find /source/path -type f \ \( -size -100M -o -name 'pattern' \) -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

With more than one allowable pattern string for "big" files:

find /source/path -type f \ \( -size -100M -o -name 'pattern1' -o -name 'pattern2' -o -name 'pattern3' \) -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

Each pattern may be something like *.mp4 or whatever file extensions you use. Note that these needs to be quoted, as in -name '*.mp4'.

Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

In two steps (for simplicity, even though these steps can definitely be combined).

First transfer "small" files:

find /source/path -type f -size -100M -print0 | rsync -av -0 --files-from=- /source/path user@server:/destination/ 

Then transfer "big" files whose filenames match pattern:

find /source/path -type f -size +99M -name 'pattern' -print0 | rsync -av -0 --files-from=- / user@server:/destination/ 

This is, however, untested.

-print0 in GNU find (and others) will print the found names with a nul delimiter, and -0 with rsync will make --files-from- interpret this standard input stream in that particular way.

The file paths read with --files-from should be relative to the specified source, that's why I use / as the source in rsync (I'm assuming /source/path in find is an absolute path).