{"id":1602,"date":"2016-02-06T14:51:28","date_gmt":"2016-02-06T22:51:28","guid":{"rendered":"http:\/\/systemsolver.com\/StatlerBlog\/?p=1602"},"modified":"2016-02-06T14:51:28","modified_gmt":"2016-02-06T22:51:28","slug":"basic-linux-tar","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2016\/02\/06\/basic-linux-tar\/","title":{"rendered":"Basic linux tar"},"content":{"rendered":"<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">I have a directory I want zipped into itself, minus the zip file of course. Actually I&#8217;m using tar which results in a &#8216;.tar&#8217; file. For background, I needed to backup some symlinks to a remote machine but rysnc didn&#8217;t want to handle symlinks that lead to nowhere on the remote machine &#8230; as a result I had to compress the folder with the symlinks then do the remote backup (when I go to restore, hopefully never, I&#8217;ll have to extract the symlinks into their proper directory).<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">My goal:<br \/>\n\/media\/files\/symlinks\/ -&gt; into -&gt; \/media\/files\/links\/directory_tar\/backup_symlinks.tar<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">What worked:<br \/>\ntar -cf \/media\/files\/links\/directory_tar\/backup_symlinks.tar &#8211;exclude=.\/directory_tar -C \/media\/files\/ symlinkslinks<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">How this worked<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">tar -&gt; linux command<\/p>\n<p data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">-cf -&gt; the &#8216;c&#8217; is &#8216;create a new archive&#8217;, the &#8216;f&#8217; is &#8216;following is a file name for this archive&#8221;<\/p>\n<p data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">\u00a0-&gt; The directory and file name for the archive<\/p>\n<p data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">&#8211;exclude -&gt; we need to exclude the tar file which is in .\/directory_tar &#8230; by using the .\/ we simplify the exclude directory. This does not exclude the directory structure (the directory \/directory.tar is included in the tar file but not any files in it).<\/p>\n<p data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">-C -&gt; means to change to the directory we want to backup. This is done so we don&#8217;t have a lot of unnecessary folder structures in the tar file, otherwise every directory from root on up would be included in the tar file (no content, but a long way to click to get to what we want)<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">\u00a0-&gt;Now we put in the directory we want to switch to<\/p>\n<p data-blkn-colour=\"rgba(51,51,51,1)\">Then there is a space<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">\u00a0-&gt; Now we put in the directory we want to backup without leading or trailing backslashes.<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">When we open the resulting archive we first see the folder &#8216;directory_tar&#8217; and within that are all our files and directories except for the tar file itself which has been excluded.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a directory I want zipped into itself, minus the zip file of course. Actually I&#8217;m using tar which results in a &#8216;.tar&#8217; file. For background, I needed to backup some symlinks to a remote machine but rysnc didn&#8217;t want to handle symlinks that lead to nowhere on the remote machine &#8230; as a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1602","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=1602"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1602\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=1602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=1602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=1602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}