LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-02-2010, 01:59 AM   #1
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
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!
 
Old 12-02-2010, 04:19 AM   #2
mac.tieu
Member
 
Registered: Jan 2010
Location: Vietnam
Distribution: Arch
Posts: 65

Rep: Reputation: 22
+1 for rsync
 
Old 12-02-2010, 04:40 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
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 04:42 AM. Reason: typos and more info
 
Old 12-02-2010, 05:35 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 12-02-2010, 09:13 AM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Lightbulb

+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>
 
Old 12-03-2010, 03:11 AM   #6
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
Thanks guys, I was also thinking rsync is better, but need it to make sure.
 
Old 12-03-2010, 09:13 AM   #7
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
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 View Post
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 09:14 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto syncing folder from Linux to Windows, SCP/Rsync? batfastad Linux - Software 2 11-26-2010 02:08 AM
Syncing local folder to webdav brunoschwartz Linux - Server 0 10-16-2010 12:02 PM
Syncing two partitions on different systems (rsync?) alk77 Linux - Software 2 07-15-2008 12:39 AM
ntp is only syncing with local clock. slackamp Linux - Server 2 11-07-2007 03:12 PM
Local rsync Yalla-One Slackware 7 09-20-2006 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration