{"id":340,"date":"2012-03-08T21:55:27","date_gmt":"2012-03-09T04:55:27","guid":{"rendered":"http:\/\/10kdev.ivystreetinc.com\/?p=340"},"modified":"2012-04-08T21:55:48","modified_gmt":"2012-04-09T04:55:48","slug":"linux-tip-compression-tar-and-exclude","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=340","title":{"rendered":"Linux Tip: Compression &#8211; tar and exclude"},"content":{"rendered":"<p>A lot of times I have to recursively compress a bunch of files and folders so I can ftp them to my local for perusal.<\/p>\n<p>When I compress, I do this:<\/p>\n<p><code><br \/>\ntar -cvzf localfolder.tar.gz localfolder<br \/>\n<\/code><\/p>\n<p>And that gives me a tar file of all the zipped stuff in localfolder.<\/p>\n<p>To decompress it on the command line I do this:<br \/>\n<code><br \/>\ntar -xvzf localfolder.tar.gz<br \/>\n<\/code><\/p>\n<p>But usually I am doing this in Windows with 7-Zip or Iceows in a GUI.<\/p>\n<p>A little more tricky thing to do is to EXCLUDE something.  Let&#8217;s say you have a folder tree like below:<\/p>\n<p><code><br \/>\n\/etc\/localfolder<br \/>\n--|folder1<br \/>\n--|folder2<br \/>\n--|folder3<br \/>\n<\/code><\/p>\n<p>But you want to exclude folder2.  The trick is to use <strong>full pathnames<\/strong> in the exclusion command or the exlclude won&#8217;t work:<\/p>\n<p><code><br \/>\ntar -cvzf localfolder.tar.gz \/etc\/localfolder --exclude=\"\/etc\/localfolder\/folder2\"<br \/>\nMultiple Exlcudes:<br \/>\ntar -cvzf localfolder.tar.gz \/etc\/localfolder --exclude=\"\/etc\/localfolder\/folder1\"  --exclude=\"\/etc\/localfolder\/folder2\"<br \/>\nWith GNU tar, swap the exclude and the source directory:<br \/>\ntar -cvzf localfolder.tar.gz  --exclude=\"\/etc\/localfolder\/folder2\" \/etc\/localfolder<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A lot of times I have to recursively compress a bunch of files and folders so I can ftp them to my local for perusal. When I compress, I do this: tar -cvzf localfolder.tar.gz localfolder And that gives me a tar file of all the zipped stuff in localfolder. To decompress it on the command [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/340"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340"}],"version-history":[{"count":4,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":469,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/340\/revisions\/469"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}