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! |
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 |
Thanks a ton! Exactly what I was looking for.
|
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. |
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! |
Quote:
Cheers, Tink |
Quote:
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! |
Oh ... that's a wuss (and the plural is wusses), though, isn't it?
Cheers, Tink |
Quote:
"-@ (that's a misspelled smiley, BTW) |
Different Words, Different Meanings
Woosie {Woosy, Woozy} pro WU-zi - is the feeling one gets when clonked on the head with a frying pan.
|
These forums are great. You learn all kinds of cool stuff.
Bill |
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. |