LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copy question (https://www.linuxquestions.org/questions/linux-newbie-8/copy-question-411047/)

ddu_ 02-02-2006 06:54 PM

copy question
 
Hey all,

I was hoping someone would be able to help me with a copy issue i'm having. I wrote a simple script to backup a directory each night at 2AM. The directory has a lot in it, subdirectories, text files, etc. I'd like to be able to copy the whole directory over but exclude one subdirectory. Is this possible to do?

for example, right now I use cp -rf /home/directory/ to copy everything, I'd like to be able to use something similiar cp -rt /home/dicrtory/* Without a specific subdirectory.

Thanks in advance!

haertig 02-02-2006 07:06 PM

The example below would backup your home directory, excluding any subdirectories named tmp. I think you'll be much happier with "rsync" instead of "cp". Run "man rsync" to see all that this program can do (and it's a LOT!)
Code:

rsync -av --exclude tmp/ /home/directory/ /backup/home/directory

ddu_ 02-02-2006 07:19 PM

Thanks a ton! Exactly what I was looking for.

Narcelio Filho 02-02-2006 07:31 PM

You can try this:
tar cf - /home/directory --exclude="*excluded_dir*" | ( cd target_dir && tar x )
tar is a good backup tool! It preserves dates, modes, owners and link-structure of all the files. Take a look for option "--exclude-from" at tar manpage if you need to exclude many directories/files.

haertig 02-02-2006 07:32 PM

just watch your trailing slashes with rsync.

"--exclude tmp" would exclude any file or directory named tmp, adding a trailing slash limits it to directories only.

Also, when specifying your source directory, /home/directory/ is
different than /home/directory It's probably easiest to test things with and without the trailing slash and observe what the difference is. Or read the manpage. Nah ... manpages are for woosies!

Tinkster 02-02-2006 08:18 PM

Quote:

Originally Posted by haertig
manpages are for woosies!

What's a woosie?


Cheers,
Tink

haertig 02-02-2006 08:45 PM

Quote:

Originally Posted by Tinkster
What's a woosie?

Well, in case this is a serious question...

More or less a derogatory slang term. Woosie: wimp, chicken, weak, not masculine, indecisive, powerless, timid, cowardly, not a leader, lacking confidence, afraid to try something new and dangerous.

That last one is the one I was joking about. A confident (not to be confused with "competant") individual would just go ahead and execute "su; rm -rf /" without reading the manpage and then deal with the consequences later. A "woosie" would never do that!

Tinkster 02-02-2006 11:03 PM

Oh ... that's a wuss (and the plural is wusses), though, isn't it?



Cheers,
Tink

haertig 02-03-2006 08:42 AM

Quote:

Originally Posted by Tinkster
Oh ... that's a wuss (and the plural is wusses), though, isn't it?

I nevur clamed I cud spel. Its knot a wurd eye youz ofen !

"-@ (that's a misspelled smiley, BTW)

Dragineez 02-03-2006 10:37 AM

Different Words, Different Meanings
 
Woosie {Woosy, Woozy} pro WU-zi - is the feeling one gets when clonked on the head with a frying pan.

wmakowski 02-03-2006 11:08 AM

These forums are great. You learn all kinds of cool stuff.

Bill

haertig 02-03-2006 11:09 AM

I'm feeling like a woosie wuss right now (although the spell-checker on this site prefers the "woozy" spelling).

You gotta learn to laugh at yourself. Because everyone else certainly is, and you'll just miss the party!


All times are GMT -5. The time now is 04:12 AM.