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
Apprentice
Apprentice


Joined: 18 Jul 2011
Posts: 176

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: 2889
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
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
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)
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2889
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
Developer
Developer


Joined: 01 Feb 2004
Posts: 3922
Location: Hamburg

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
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
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.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2889
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
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
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.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
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