Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with usage of cp
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
alex6
Tux's lil' helper
Tux's lil' helper


Joined: 18 Jul 2011
Posts: 139

PostPosted: Sat Feb 08, 2014 3:21 pm    Post subject: Problem with usage of cp Reply with quote

My goal is to make a backup but not erase existing files using cp.
After reading "man cp", I tried "cp -rn", but I have a strange output :

Quote:
cp: cannot create regular file ‘/mnt/plouf/alex32/Desktop/b/analysis/1765.libardourvampplugins:percussiononsets:2’: No such file or directory


So it seems it can't create a file to the destination if the directory is not present...?
How can I do ?

I don't want to use rsync because it takes forever and I only want new files/directories to be copied
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2861
Location: Omnipresent

PostPosted: Sat Feb 08, 2014 3:35 pm    Post subject: Reply with quote

rsync with the "-a" option only copies differences and preserves permissions, timestamps, etc. -- it's a proper backup.

cp with the "-a" option will do much the same.

These behaviors are described in the respective man pages.

If you want a scripted solution, check out my backup howto linked in my signature.
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 2105
Location: Dallas area

PostPosted: Sat Feb 08, 2014 4:40 pm    Post subject: Reply with quote

I've not noticed a lot of speed difference between rsync and cp -ap or cp-apu (copy only if newer)
_________________
Asus m5a99fx, FX 8320 - amd64-multilib, 3.9.1-zen, eudev
glibc-2.17, gcc-4.7.3-r1, xorg-server-1.15, lxde, nouveau, oss4
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2861
Location: Omnipresent

PostPosted: Sat Feb 08, 2014 5:42 pm    Post subject: Reply with quote

Anon-E-moose wrote:
I've not noticed a lot of speed difference between rsync and cp -ap or cp-apu (copy only if newer)

Which is faster? Are you making sure to compare across different filesystems, which is the usual application of rsync?
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
toralf
Advocate
Advocate


Joined: 01 Feb 2004
Posts: 2619
Location: Hamburg/Germany

PostPosted: Sat Feb 08, 2014 6:25 pm    Post subject: Re: Problem with usage of cp Reply with quote

alex6 wrote:
My goal is to make a backup but not erase existing files using cp.
After reading "man cp", I tried "cp -rn", but I have a strange output :

Quote:
cp: cannot create regular file ‘/mnt/plouf/alex32/Desktop/b/analysis/1765.libardourvampplugins:percussiononsets:2’: No such file or directory

Check for an unusual file name and/or wgetpaste the whole command line + terminal output.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 2105
Location: Dallas area

PostPosted: Sat Feb 08, 2014 7:15 pm    Post subject: Reply with quote

Hypnos wrote:
Anon-E-moose wrote:
I've not noticed a lot of speed difference between rsync and cp -ap or cp-apu (copy only if newer)

Which is faster? Are you making sure to compare across different filesystems, which is the usual application of rsync?


Yes, I've actually used both across file systems on different disks.
I was manually running a cp -apu once a week or so, before I swapped to rsync run by cron.
There may be a time difference between them, but to me it's a small difference in my testing while getting rsync set up.

Note: I didn't time it with a stopwatch, just subjective waiting for it to finish.
Also these were on sata 2/3 to either the esata port or my usb3 backup disks.

Edit to add: if one uses the delete option of rsync, then it will be slower than a straight copy,
but will be comparable to a cp + rm of whatever files.
_________________
Asus m5a99fx, FX 8320 - amd64-multilib, 3.9.1-zen, eudev
glibc-2.17, gcc-4.7.3-r1, xorg-server-1.15, lxde, nouveau, oss4
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2861
Location: Omnipresent

PostPosted: Sat Feb 08, 2014 7:31 pm    Post subject: Reply with quote

Anon-E-moose wrote:
Edit to add: if one uses the delete option of rsync, then it will be slower than a straight copy,
but will be comparable to a cp + rm of whatever files.

This would make sense, they're all using the same system calls to create and unlink files.
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 2105
Location: Dallas area

PostPosted: Sat Feb 08, 2014 7:54 pm    Post subject: Reply with quote

Back to the original question.

I'm not sure what you were trying to do.

Can you post the whole cp command that you were using?
I can't tell from the message in the original post whether it was from the source or the destination.


Edit to add: As an example

cp -rn /src/dir_of_files /dest/
then /dest must exist and must be writable by whoever the user is and it will leave dir_of_files under /dest, ie /dest/dir_of_files
This hold true no matter how many levels of destination directories you have.

cp -rn /src/dir_of_files /dest/dir1/dir2
then /dest/dir1/dir2 all must exist.
_________________
Asus m5a99fx, FX 8320 - amd64-multilib, 3.9.1-zen, eudev
glibc-2.17, gcc-4.7.3-r1, xorg-server-1.15, lxde, nouveau, oss4
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum