SPnova
SPnova

Reputation: 489

How to create tar archive without some folders?

How I can create tar archive without some folders?

Now I'm creating tar archive of folder and deleting some folders from it. But it is takes long time.

Structure:

www
- sub f 1
- sub f 2
- sub f 3

need create archive only with folders (sub f 1) and (sub f 2) (It is only for example, my really structure have more sub levels)

Thanks!

Upvotes: 3

Views: 4969

Answers (2)

In addition of the --exclude option suggested by Ajreal, you could use some other tar option (from the --help output):

  --exclude=PATTERN      exclude files, given as a PATTERN
  --exclude-backups      exclude backup and lock files
  --exclude-caches       exclude contents of directories containing
                         CACHEDIR.TAG, except for the tag file itself
  --exclude-caches-all   exclude directories containing CACHEDIR.TAG
  --exclude-caches-under exclude everything under directories containing
                         CACHEDIR.TAG
  --exclude-tag=FILE     exclude contents of directories containing FILE,
                         except for FILE itself
  --exclude-tag-all=FILE exclude directories containing FILE
  --exclude-tag-under=FILE   exclude everything under directories
                         containing FILE
  --exclude-vcs          exclude version control system directories
-X, --exclude-from=FILE    exclude patterns listed in FILE

and you could also use tardy, a tar post-processor (which is packaged in Debian)

Upvotes: 2

ajreal
ajreal

Reputation: 47331

Does this works ?

tar -cf backup.tar --exclude "www/subf3" www
// is your directory with spaces?

Upvotes: 9

Related Questions