Ubuntu – Using tar to only backup specific folders

backuptar

I only want to backup the following folders with my tar command:

/var/www
/home/myuser/importantFiles
/home/myuser/anotherFolder

And I want these folders to be backed up in the very same .tar.gz archive, how can I achieve this? Do I really have to use –exclude to set it to every other folder that I don't want backed up?

Best Answer

Nevermind, I was overlooking the obvious by simply doing this:

tar -cvpzf backup.tar.gz /var/www /home/myuser/importantFiles /home/myuser/anotherFolder