Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

tar exclude not working for directories

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
Jerri
Guru
Guru
User avatar
Posts: 353
Joined: Thu Apr 03, 2003 9:47 pm

tar exclude not working for directories

  • Quote

Post by Jerri » Sat Mar 05, 2005 3:24 am

Well, as the subject suggests, i'm trying to backup some files (well, my whole system) but tar is not cooperating.

the following command *does* work:

Code: Select all

pwd
/usr/src/linux/kernel
tar  --exclude=irq -cvf new.tar ./
it succesfully removes the directory irq, and everything underneath it. However, if i'm trying to backup my entire system, i wont to specify the exact path to the directory to be excluded.

the following commands *do not* work:

Code: Select all

pwd
/usr/src/linux/kernel
tar  --exclude=/usr/src/linux/kernel/irq -cvf new.tar ./
tar  --exclude=/usr/src/linux/kernel/irq/ -cvf new.tar ./
tar  --exclude=/usr/src/linux/kernel/irq/* -cvf new.tar ./
tar  --exclude="/usr/src/linux/kernel/irq" -cvf new.tar ./
tar  --exclude="/usr/src/linux/kernel/irq/" -cvf new.tar ./
tar  --exclude='/usr/src/linux/kernel/irq' -cvf new.tar ./
tar  --exclude='/usr/src/linux/kernel/irq/' -cvf new.tar ./
snippet of whats tarred:

Code: Select all

intermodule.c
intermodule.o
irq/
irq/.autoprobe.o.cmd
irq/Makefile
irq/.manage.o.cmd
irq/internals.h
irq/spurious.c
irq/spurious.o
irq/.handle.o.cmd
irq/.built-in.o.cmd
irq/manage.c
irq/manage.o
irq/handle.c
irq remains! ahhh!!


I'm going crazy over this tiny little thing (i guess thats how it usually goes).

I'm all ears for suggestions.
Top
jdgill0
Veteran
Veteran
User avatar
Posts: 1366
Joined: Tue Mar 25, 2003 10:12 pm
Location: Lexington, Ky -- USA

  • Quote

Post by jdgill0 » Sat Mar 05, 2005 3:33 am

Looking at the man page for tar:

Code: Select all

       --wildcards
              use wildcards with --exclude

       --wildcards-match-slash
              wildcards match slashes (/) with --exclude

       --exclude PATTERN
              exclude files based upon PATTERN

       -X, --exclude-from FILE
              exclude files listed in FILE

It looks like the slashes are the problem. You should try the --wildcards-match-slash option, or you can put /usr/src/linux/kernel/irq within a file and use the -X, --exclude-from FILE option, which I know will work.
Top
Jerri
Guru
Guru
User avatar
Posts: 353
Joined: Thu Apr 03, 2003 9:47 pm

  • Quote

Post by Jerri » Sat Mar 05, 2005 3:37 am

no dice, i tried exclude-from FILE, same results. i'm really stumped here...

Code: Select all

[root][/usr/src/linux/kernel]: tar  --wildcards-match-slash --exclude=/usr/src/linux/kernel/irq/* -cvf new.tar * | grep irq
tar: new.tar: file is the archive; not dumped
irq/
irq/.autoprobe.o.cmd
irq/Makefile
irq/.manage.o.cmd
irq/internals.h
irq/spurious.c
irq/spurious.o
irq/.handle.o.cmd
irq/.built-in.o.cmd
irq/manage.c
irq/manage.o
irq/handle.c
Top
jdgill0
Veteran
Veteran
User avatar
Posts: 1366
Joined: Tue Mar 25, 2003 10:12 pm
Location: Lexington, Ky -- USA

  • Quote

Post by jdgill0 » Sat Mar 05, 2005 3:46 am

OK. Tried this myself. The problem is because of the ./ is not an absolute path, hence the absolute path /usr/src/linux/kernel/irq does not match anything in ./.

For example, to backup /usr/src/linux without irq.

Code: Select all

tar  --exclude=/usr/src/linux/kernel/irq -cvf new.tar /usr/src/linux
Top
Jerri
Guru
Guru
User avatar
Posts: 353
Joined: Thu Apr 03, 2003 9:47 pm

  • Quote

Post by Jerri » Sat Mar 05, 2005 3:49 am

thanks, that gives me some ideas :)
Top
Jerri
Guru
Guru
User avatar
Posts: 353
Joined: Thu Apr 03, 2003 9:47 pm

  • Quote

Post by Jerri » Sat Mar 05, 2005 4:03 am

jdgill0 you are the man.

Thanks you so much :)
Top
jdgill0
Veteran
Veteran
User avatar
Posts: 1366
Joined: Tue Mar 25, 2003 10:12 pm
Location: Lexington, Ky -- USA

  • Quote

Post by jdgill0 » Sat Mar 05, 2005 4:07 am

:) I actaully learned something myself. I never noticed this "quirk" about tar before. Guess I have been lucky and not run into it ever :!:

Anyways, glad I could help. Good luck.
Top
Post Reply

7 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy