LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-02-2006, 07:54 PM   #1
ddu_
Member
 
Registered: Dec 2004
Distribution: Slackware
Posts: 114

Rep: Reputation: 16
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!
 
Old 02-02-2006, 08:06 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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
 
Old 02-02-2006, 08:19 PM   #3
ddu_
Member
 
Registered: Dec 2004
Distribution: Slackware
Posts: 114

Original Poster
Rep: Reputation: 16
Thanks a ton! Exactly what I was looking for.
 
Old 02-02-2006, 08:31 PM   #4
Narcelio Filho
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Rep: Reputation: 0
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.
 
Old 02-02-2006, 08:32 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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!
 
Old 02-02-2006, 09:18 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by haertig
manpages are for woosies!
What's a woosie?


Cheers,
Tink
 
Old 02-02-2006, 09:45 PM   #7
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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!
 
Old 02-03-2006, 12:03 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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



Cheers,
Tink
 
Old 02-03-2006, 09:42 AM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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)
 
Old 02-03-2006, 11:37 AM   #10
Dragineez
Member
 
Registered: Oct 2005
Location: Annapolis
Distribution: Ubuntu
Posts: 275

Rep: Reputation: 32
Different Words, Different Meanings

Woosie {Woosy, Woozy} pro WU-zi - is the feeling one gets when clonked on the head with a frying pan.
 
Old 02-03-2006, 12:08 PM   #11
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
These forums are great. You learn all kinds of cool stuff.

Bill
 
Old 02-03-2006, 12:09 PM   #12
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DVD copy...question JT13 Linux - Software 1 06-06-2005 02:01 PM
Copy Music CD question. akihandyman General 3 06-05-2005 06:58 PM
XFree86Config File Copy Question. rvijay Linux - Newbie 2 09-20-2003 06:23 PM
DVD copy question (using an ISO) eallen Linux - Software 4 03-11-2003 12:00 AM
Easy Question on Copy Command aklinuxuser Linux - Newbie 1 08-29-2001 06:55 PM


All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration