so the questions is, how do you tar a backup without including these two directories?
well the answer is easy, when you are done reading this short tutorial, you will learn how you can exclude a file or a directory in your tars.
ok, here is my example,
1. - i want to keep the same permission on each file and directory (-pczf)
2. - the name of my backup tar file is called mywebsites.tar.gz
3. - i wanted to backup my entire /var/www directory
4. - the two directories i did not want to put in my tar backup are:
- /var/www/mydomain/images/
- /var/www/otherdomain/pictures/
now that i have all these elements, i can construck the shell command im going to use in my linux server. so here is the command
tar -pczf mywebsites.tar.gz /var/www/ --exclude="/var/www/mydomain/images/" --exclude="/var/www/otherdomain/pictures"
so basically if you want to exclude a file that you dont want to be included in your tar, just use the --exclude option. easy huh
thats it
hope this helps
UPDATE, you can try this small test tutorial to see how it works: just send these command when you are logged into your shell terminal:
lets make a test directory and two other directories, one good and the other bad.
mkdir -p test/good test/bad
now lets create the archive of the test directories and its subdirectories, but exclude the bad/ directory
tar -pczf test.tar.gz test --exclude="test/bad"
we remove the old test directory
rm -rf test
now we extract the test directory
tar xvfz test.tar.gz
you will see a the verbose:
test/
test/good/
shows that test/bad/ was not created in the tarball

