Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
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.
Would someone explain to me how to use "cp -u" properly, or what I'm doing wrong in using it? According to man cp, it is supposed to back up only files that had changed since the last backup or files that don't exist on the last backup. So I entered this:
@AlucardZero: You need to loose the single quotes, even when using -r. Expansion is done before the cp command takes effect.
I do suspect that newbiesforever's initial command (cp -u '/home/josh' '/mnt/sdb1/josh') would have worked without the single quotes (ie: cp -u /home/josh /mnt/sdb1/josh).
If it has a voiced Z sound, then it’s “lose.” If it has a hissy S sound, then it’s “loose.” Here are examples of correct usage: “He tends to lose his keys.” “She lets her dog run loose.” Note that when “lose” turns into “losing” it loses its “E.”
Code:
alucard@organa:/tmp$ mkdir -p a/b/c
alucard@organa:/tmp$ mkdir -p d
alucard@organa:/tmp$ cp a d
cp: omitting directory `a'
alucard@organa:/tmp$ cp 'a' 'd'
cp: omitting directory `a'
alucard@organa:/tmp$ cp -r 'a' 'd'
alucard@organa:/tmp$ ls d/a/b
c
alucard@organa:/tmp$ mkdir a/e
alucard@organa:/tmp$ ls d/a
b
alucard@organa:/tmp$ cp -ur 'a' 'd'
alucard@organa:/tmp$ ls d/a
b e
There is no expansion in the following command because there are no wildcards:
If you put files inside the directories you'll see it fails:
Code:
mkdir -p a/b/c
mkdir -p d
touch a/{1,2} a/b/{3,4} a/b/c/{5,6}
ls a a/b a/b/c
a:
1 2 b
a/b:
3 4 c
a/b/c:
5 6
cp a d (omitted, same result)
cp 'a' 'd' (omitted, same result)
cp -r 'a' 'd'
ls -l *
a:
total 4
-rw-r----- 1 druuna internet 0 Oct 25 22:08 1
-rw-r----- 1 druuna internet 0 Oct 25 22:08 2
drwxr-x--- 3 druuna internet 4096 Oct 25 22:08 b
d:
total 4
drwxr-x--- 3 druuna internet 4096 Oct 25 22:08 a
ls d/a/b
3 4 c
file 1 and 2 are missing from d, same is tru for the cp -ur 'a' 'd' command.
This cp -r a/* d will work. Without the single quotes!
Okay, I'll try these procedures, but I don't understand what copying files recursively (cp -r) means. I saw it in man cp, but since I didn't understand what copying files recursively meant, I didn't know how it could help me.
Yes, thank you. If that's what it means, I guess I obviously need it. Since I understand only in the most abstract sense what recursion means (procedures referring to themselves), I thought it might be more complicated than copying all the subdirectories and their files.
I do suspect that newbiesforever's initial command (cp -u '/home/josh' '/mnt/sdb1/josh') would have worked without the single quotes (ie: cp -u /home/josh /mnt/sdb1/josh).
is incorrect.
Code:
alucard@organa:~$ mkdir -p a/b/c
alucard@organa:~$ touch a/b/c/{d,e}
alucard@organa:~$ mkdir f
alucard@organa:~$ cp -u a f
cp: omitting directory `a'
alucard@organa:~$ cp -u 'a' 'f'
cp: omitting directory `a'
alucard@organa:~$
Other than that I think we're saying the same thing.
cp -r appears to have worked, judging by the new dates of files and folders in the backup copy--they are reflecting the date and time they were changed. But in the console window, the output stopped displaying for some reason. After displaying
Quote:
cp -ur '/home/josh' '/mnt/sdb1'
...it never continued, but never returned to the command prompt either.
Last edited by newbiesforever; 10-25-2009 at 05:25 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.