Also rsync has a --delete option that you might find useful. It's not really a question of what's more efficient. The commands 'rsync', and 'cp' are not equivalent and achieve different goals. So bottom line is rsync is for large data, and cp is for smaller local copying. MB to small GB range. When you start getting into multiple GB or in the TB range, go with rsync.
And of course network copies, rsync all the way. Keep in mind that while transferring files internally on a machine i. Lets say you have this folders:. It took me three days. It is a typical overbuffering issue. As often happens, I discovered the "-z" flag only after I wondered about the issue and looked for an understandment. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Copy or rsync command Ask Question. Asked 10 years, 5 months ago. Active 1 month ago. The other command that is fast and very versatile for copying files between two locations is rsync. It can be used to copy between local as well as remote locations. In the above example, copying is being done locally, but you can use rsync for copying over remote locations also.
Although rsync is not generally faster than cp, but as it only syncs files that are modified or new. It can offer better speed when synchronizing files. The rsync also has multiple advanced options that are not available in cp. These commands will install rsync on your system. Now you can try copying files with a better speed. Secure copy or also known as SCP, can also be used for copying. Although it is not for fast copying, it can be used for the secure transmission of files between a local host and a remote host.
Or between two remote hosts. So when you are looking for secure transmission of files you can use this method. You are commenting using your WordPress. Tar also uses multiple threads to read and write and can even several files at once.
This makes tar clearly win in comparison of cp vs tar. As tar works in a more speedy and efficient way. The other command that is fast and very versatile for copying files between two locations is rsync. It can be used to copy between local as well as remote locations.
In the above example, copying is being done locally, but you can use rsync for copying over remote locations also. You can also use like n for the dry run to perform a trial run without synchronization and r for recursive sync files and directories recursively.
If you are transferring from a remote location you can also use -e ssh to secure communications. So what do you reckon, rsync or cp? Improve this question. Carolus 9 9 bronze badges. Amandasaurus Amandasaurus If rsync does exactly what you want it to do, if you are quite familiar with its usage for this particular application already, and if it functions quickly enough to suit your taste, then why on earth would you want to switch?
Because I'm concerned that rsync will take longer than cp, since rsync does lots of checksumming that cp won't do — Amandasaurus. Unless the disk are on the same system and the OS can do some clever drive-drive copy in the bus controller. Checksumming is done on files that differ at the size and timestamp check.
If you're paranoid like after a power outage during copy you can force checksumming on all files, but on a local transfer, that's usually slower than starting from scratch. Maybe he's curious about improving his workflow, and doesn't bury his head in the sand thinking he knows everything. This comment really annoys me. Show 1 more comment. Active Oldest Votes. Thus, for a robust copy of a filesystem, you'll need to include those flags: rsync -aHAX source dest Linux rsync -aHE source dest OS X The default cp will start again, though the -u flag will "copy only when the SOURCE file is newer than the destination file or when the destination file is missing".
So: cp -au source dest. Improve this answer. Hamish Downer Hamish Downer 8, 6 6 gold badges 35 35 silver badges 49 49 bronze badges. The nice thing about rsync is that you can have it md5 sum the files to detect differences. It's useful for copying large files, not for many thousands small files as it means lots more output which you can't read. It doesn't show the overal progress of all files combined.
Useful to give an approximation during large transfers. Show 9 more comments. Ellis Percival Ellis Percival 1, 1 1 gold badge 10 10 silver badges 5 5 bronze badges.
I am having following error: rsync: --no-compress: unknown option Ellis Percival. Add a comment. Chad Huneycutt Chad Huneycutt 2, 1 1 gold badge 16 16 silver badges 14 14 bronze badges. I like the idea of finishing off with a final rsync, too. That's the beauty of this method. You do not need double the space because you never actually create an intermediate tar file. The tar before the pipe packs the data and streams it to stdout, and the tar after the pipe grabs it from stdin and unpacks it.
I did a cp -a for a 12gb transfer, and this method for a 42gb transfer. I also put pv in the middle to be able to watch the progress, estimating the size of all the data using df. Show 6 more comments. It's about as fast as tar, maybe a little quicker. AskApache AskApache 3 3 silver badges 5 5 bronze badges. Why do you use the -S and -D flags for rsync?
D preserves Specials and System files, while S "handle sparse files efficiently" not sure why rsync wouldn't just do that by default. In what way is cpio safer than rsync? Why not benchmarking cp? This is the title of the question! What does the -p flag do again?
0コメント