Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-02-2010, 02:59 AM
|
#1
|
Member
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749
Rep:
|
Which is better: cp or rsync for local syncing/coping
Hello, I would if any of you know and can tell me which of this would be better when trying to copy locally files/directories from disk sda5 for example to disk sdb5?
Im talking about at least 1GB of data and as I know rsync can compress the data before or while coping so I consider rsync a bit better, but I don't know for sure.
I wanna know more or less which is safer, faster and makes sure it copies the exact data without any issue.
Thanks!
|
|
|
12-02-2010, 05:19 AM
|
#2
|
Member
Registered: Jan 2010
Location: Vietnam
Distribution: Arch
Posts: 65
Rep:
|
+1 for rsync
|
|
|
12-02-2010, 05:40 AM
|
#3
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep: 
|
Rsync is the tool for synchronising data from source to destination. It is made for the specific purpose. And it is faster than cp as well. And when you say the data goes into gig bytes, +1 for rsync.
I use rsync to sync the mysql db for bugzilla over the network and it is at least 5 times faster than cp even though the data does not reach the gig limit.
Last edited by linuxlover.chaitanya; 12-02-2010 at 05:42 AM.
Reason: typos and more info
|
|
|
12-02-2010, 06:35 AM
|
#4
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,336
|
Rsync has better public relations support. My tracing of functionality (especially with sparse files where I was interested at the time) showed "cp" to be markedly more efficient.
YMMV.
|
|
|
12-02-2010, 10:13 AM
|
#5
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
+6 total for Rsync (1 for speed, 5 for progress indicator)
As you can see below - 'rsync' is faster by more than 10%, and has a handy indicator -- where 'cp' does not.
Speed test:
Code:
"time rsync -varh --progress (15G folder/29650 files) (some destination on same drive)"
OUTPUT
total size is 15.02G
real 4m28.815s
user 0m59.163s
sys 0m27.270s
"time cp -a (15G folder/29650 files) (some destination on same drive)"
OUTPUT
real 6m12.800s
user 0m1.418s
sys 0m21.759s
Progress indicator test:
Code:
"rsync -varh --progress (something) (somewhere)"
Output
/dir/dir/dir/file.txt 24.69M 100% 74.51MB/s 0:00:00 (xfer#28470, to-check=340/29650)[/QUOTE]
"cp -a (something) (somewhere)"
Output:
# > <intentionally blank>
|
|
|
12-03-2010, 04:11 AM
|
#6
|
Member
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749
Original Poster
Rep:
|
Thanks guys, I was also thinking rsync is better, but need it to make sure.
|
|
|
12-03-2010, 10:13 AM
|
#7
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824
|
rsync has the added bonus of being able to resume copies partway (even partway through a file if you use --partial).
Quote:
Originally Posted by syg00
Rsync has better public relations support. My tracing of functionality (especially with sparse files where I was interested at the time) showed "cp" to be markedly more efficient.
YMMV.
|
Did you include rsync's -S option?
Last edited by AlucardZero; 12-03-2010 at 10:14 AM.
|
|
|
All times are GMT -5. The time now is 07:35 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|