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).
