|
|
Subscribe / Log in / New account

rsync -a is not the same as cp -R

rsync -a is not the same as cp -R

Posted Nov 6, 2020 7:55 UTC (Fri) by mchehab (subscriber, #41156)
In reply to: Deprecating scp by marcH
Parent article: Deprecating scp

> It is true that rsync can do everything but the kitchen sink but in practice there are only two rsync things you need to remember:
>
> - Use -a ("archive") always.
> - The infamous source trailing slash: on the source side, foo/ is equivalent to foo/*, including dot files
>
> And that's it, I never remember anything else. Plus who reads man pages from top to bottom? I have no idea how long most man pages are because I only search them.

You should revisit your concept and read the manuals ;-)

> tl;dr: cp -R is insane, use rsync -a. Using it more than once is not just safer it's also much faster of course: it can be used as an actual backup tool.

If you're copying big sparse file(s) (for instance, VM images) and don't use -S on rsync, you may end running out of disk space at the destination, as rsync will create a non-sparsed files at the destination. See:

    $ dd if=/dev/zero of=test bs=1k seek=2048k count=1
    $ rsync -a test test2
    $ du -h test test2
       4,0K	test
       2,1G	test2
Also, depending on the type of file permissions, "-a" is not enough. You may need other flags (-A, -H, -X).


to post comments

rsync -a is not the same as cp -R

Posted Nov 6, 2020 8:06 UTC (Fri) by Wol (subscriber, #4433) [Link] (3 responses)

My photographs directory (large files, 24MP raw) is heavily sym-linked. Does -a retain hard symlinks - I believe not. Copying that directory could well cause a "disk full" on the destination, too ...

Cheers,
Wol

rsync -a is not the same as cp -R

Posted Nov 6, 2020 10:01 UTC (Fri) by taneli (subscriber, #95265) [Link]

Indeed, you will need -H to preserve hard links.

rsync -a is not the same as cp -R

Posted Nov 7, 2020 23:22 UTC (Sat) by Sesse (subscriber, #53779) [Link] (1 responses)

FWIW, links in UNIX are either hard (hardlinks) or symbolic (symlinks). There's no such thing as “hard symlinks”.

rsync -a is not the same as cp -R

Posted Nov 8, 2020 0:03 UTC (Sun) by Wol (subscriber, #4433) [Link]

Whoops :-)

I meant, of course, hard links.

Oh - and if you don't need to preserve hard links (which I do), it's not a good idea to try. I think my rsync or cp crawled, I had so many it needed to keep track of ...

Cheers,
Wol


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds