using cp -u command
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:
Quote:
Quote:
|
CP
Why not try /my/folder/* ?
|
From the cp man page:
Quote:
Code:
josh@mepis1:~$ cp -u '/home/josh/*' '/mnt/sdb1/josh' |
Okay, I just tried that. The response was:
Quote:
|
Hi,
Do away with the single quotes, use double quotes if you have to. Single quotes prevents bash from doing expansion, so /home/josh/* is taken literal (a file called * in /home/josh). Hope this helps. |
Alternately, use cp's -r option
|
@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 Code:
josh@mepis1:~$ cp -u '/home/josh' '/mnt/sdb1/josh' |
What are you trying to say with the cp examples?
If you put files inside the directories you'll see it fails: Code:
mkdir -p a/b/c This cp -r a/* d will work. Without the single quotes! |
what is copying files recursively?
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.
|
Hi,
If you use: cp /somedir/* /someotherdir only the files in /somedir/ are copied, not the subdirectories and all its files. The -r option tells cp that it should also copy subdirectories and its files. I think you are looking for something like this: cp -ur /home/josh/* /mnt/sdb1/josh/ Hope this helps. |
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.
|
Quote:
Quote:
Code:
alucard@organa:~$ mkdir -p a/b/c 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:
|
It was probably still going. Give it -v too. And I like -a as well.
|
All times are GMT -5. The time now is 09:02 AM. |