LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 01: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, 06:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

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

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
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, 07:11 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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 10:19 AM.
 
Old 11-16-2006, 09:59 AM   #5
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Original Poster
Rep: Reputation: 31
Thank you!
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:08 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
Open Source Consulting | Domain Registration