How to exclude a folder when using TAR to archive

I’m generally using the “tar” utility to backup my stuff, but sometimes I need to exclude some folders, especially very large folders such as those for Videos or Virtual Machines, this is the syntax you need to use:

tar -cvf /media/L_AAMR/slash_home_before_Oneric_25_Oct_2011.tar /home/aamr –exclude=VirtualBox\ VMs/

In the above example, I tarred all the contents of my home folder “/home/aamr” onto a TAR file inside my external HDD: “/media/L_AAMR/slash_home_before_Oneric_25_Oct_2011.tar” excluding the Virtual Machines folder “VirtualBox\ VMs/”, I used the relative path here as I was standing on “/home/aamr”.

Update: For some reason the folder with spaces “VirtualBox\ VMS/” didn’t work out, so I used a wildcard instead “Virtualbox*” and it ran correctly.

About SoCRaT

Systems Engineer, OSS & Linux Geek
This entry was posted in Ubuntu and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s