July 22, 2014 844 Views 1 Comment

Uinx Command – Archive ALL Files Except…


Creating a tarball of the files on your server is a quick and easy way of completing a backup. The only issue is that in a real world scenario there’s always some file types or directories which you really don’t wish to backup be it space concern or otherwise.

Skip Images when Creating TAR.GZ

To skip images when creating a tarball use the –exclude parameter with the image extension. Please note that extension names are case sensitive so *.jpg is not the same as *.JPG.

tar -cvf myBackup.tar.gz --exclude='*.png' --exclude='*.gif' --exclude='*JPG' --exclude='*.JPEG' --exclude='*.jpeg' myFiles

Skip Folders

Skipping directories can be achieved using the same –exclude parameter. the example below will not archive the logs or the backup directories.

tar -cvf myBackup.tar.gz --exclude='logs' --exclude='backup' myFiles
  • John

    This is exactly what I was looking for! I thought about the “exclude” parameter, but I do not think I was using it correctly for it to work. Thanks for the tip!