6

I have 3 drives. For this purpose, we will call them A, B and C respectively.

A is 2 TB

B is 1 TB

C is 500 GB

I have already run

rsync -avz -progress A B

Now B is full and I want to move/copy what is not already on B from A to C

It really doesnt matter to me what happens to what is on A as I will reformat anyways.

2
  • You want to move it, or you want to copy it?
    – Flimzy
    Nov 30, 2012 at 3:22
  • I just want to copy it.
    – cripto
    Nov 30, 2012 at 3:23

2 Answers 2

6

Make a list of all the files on B, say with the the find command by going to that drive and running:

$ find . > files-on-b.xt

Then when you rsync from A to C, specify that list in the --exclude-from parameter:

$ rsync -avz --exclude-from=files-on-b.txt A C

You may need to futz with the prefixes in the list to makes sure it matches the format/relative directory that rsync is expecting from an exclude list. Always a good idea to run rsync with the -n option to see what it's about to do without actually doing it.

See rsync man page and this helpful blog post for more on --exclude-from.

4

You can make use of the --compare-dest option. This saves some time and space, as you don’t have to enumerate the whole contents of the first destination, and will work incrementally with many targets. Here’s how it works: After copying the contents from A to B, you run:

rsync -avz --compare-dest=/path/to/B /path/to/A/ /path/to/C/

rsync will use the contents of B to see what it has to transfer to C to make the copy of A complete. Anything which is already in B won’t be transferred. Note that absolute paths for --compare-dest are required, otherwise the path is taken as relative to the destination.

If you in any event have to split your destination further, you can compare to multiple previous targets by adding more --compare-dest arguments.

1
  • The only drawback I see to this approach is that you have to have all drives mounted, whereas with enumerating the contents of the drives you have filled only needs to be once and then those drives can be offline when you do subsequent syncs...
    – Michael
    Jul 18, 2022 at 0:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .