www.pokeroconnor.com

Tarball Options and Uses

July20

Here’s a few tidbits on tarballs that are quite useful. In case you’re wondering how to create a tarball in the first place, do this:

tar -zcvf my_first_tarball.tar.gz /home/my_code

where my_first_tarball.tar.gz is the name of the tarball that will be created, and /home/my_code the dir that is being compressed.

But you really need to know how to exclude files and/or directories when creating tarballs. For example, say you want to backup your codebase, but exclude all the SVN crap, then this is essential.

So you simply add –exclude options, like so:

tar -zcvf /my_first_tarball.tar.gz –exclude=’svn’ –exclude=’*.svn’ /home/my_code

This blog has a great example too of how you can list all your exclude types in a file, and use the -X switch to exclude them all – very neat.

One of the most common uses of tarballs is of course backing stuff up. So here’s a really useful script, running on a cron, to backup your stuff. I won’t reproduce it here, just check out the link.

Email will not be published

Website example

Your Comment: