Wednesday, November 14, 2012

Using "tar" to backup and exclude files in a script.

I needed to create a manual backup script that I could easily modify to backup specific directories and files while excluding others.  I was having a difficult time excluding files and directories without having to type out each exclusion using --exclude=somefile --exclude=some_other_file --exclude=somedirectory.  My "tar" command would have grown quite large and, in my opinion, is not easy to read. So, I decided to use an array to accomplish my goal.