LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 11-15-2006, 02:03 PM   #1
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
Ignore specific sub directories when using tar


Hey,

I want to backup my /home/mcarrick/ directory to a external usb drive mounted at /media/disk-1/, however, I want to ignore the 'downloads' and 'video' subdirectories. How can I do this?

I was using:

Code:
tar czf /media/disk-1/backup/local/mcarrick_11-15-2006.tar.gz /home/mcarrick/
 
Old 11-16-2006, 07:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,743
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
Add "--exclude ~/somedirname"
 
Old 11-16-2006, 07:19 AM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 144Reputation: 144
Try this:
Code:
tar czf /media/disk-1/backup/local/mcarrick_11-15-2006.tar.gz --exclude=/downloads/ --exclude=/video/ /home/mcarrick/
 
Old 11-16-2006, 08:11 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You can also list the patterns you wish to exclude in a file, and use that like this:
Code:
echo "/home/mcarrick/video" >> ~/my_excludes
echo "/home/mcarrick/downloads" >> ~/my_excludes
tar czf /path/to/backup_file.tar.gz  --exclude-from=~/my_excludes /home/mcarrick/
Depending on how you are working, this may or may not be more easily maintainable than using multiple --exclude=... options on the command line. My personal opinion is that it is clearer if you have a lot of excludes to do, and is especially useful if you do frequent tar operations and every so often need to change the list.

{edit: changed ~/my_excludes filename mismatch between echo and tar commands}

Last edited by matthewg42; 11-16-2006 at 11:19 AM.
 
Old 11-16-2006, 10:59 AM   #5
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Original Poster
Rep: Reputation: 31
Thank you!
 
  


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
FC5 - ls hangs in specific directories from tar ball scottflyer Fedora 1 05-22-2006 05:53 PM
How To extract .tar.gz To A Specific Directory? George2 Linux - Software 4 02-18-2006 08:01 AM
Excluding directories from tar? LocoMojo Linux - Software 6 01-24-2006 02:01 AM
how to rsync ex/include select specific directories ? dtimms Linux - Software 1 01-11-2005 06:16 AM
Find files, directories that are own by specific user mikeshn Linux - General 2 02-12-2004 04:52 PM


All times are GMT -5. The time now is 07:14 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration