{"id":44,"date":"2008-10-23T20:52:15","date_gmt":"2008-10-24T01:52:15","guid":{"rendered":"http:\/\/xux.in\/blog\/?p=44"},"modified":"2021-06-19T19:46:00","modified_gmt":"2021-06-20T01:46:00","slug":"quick-ensim-backup","status":"publish","type":"post","link":"http:\/\/xux.in\/blog\/post\/quick-ensim-backup\/","title":{"rendered":"Quick Ensim Backup"},"content":{"rendered":"<p>Nothing but an easy to use backup script for Ensim (4.X-10.X) which uses vhexport, so yeah, it&#8217;s not fast, but I wrote it because sometimes you just need to backup 1 or a few sites and drop them somewhere \ud83d\ude1b<\/p>\n<p>You just need to type this:<\/p>\n<pre lang=\"sh\">.\/backupsingle.php \/path\/to\/backup domain1.com domain2.com ...domainN.com<\/pre>\n<p>And you&#8217;ll see something like this:<\/p>\n<pre lang=\"sh\">Building site's structure... found NN sites\nBuilding backup for N site(s)\n\nStarting backup for domain domain1.com (site1)... [OK]\nStarting backup for domain domain2.com (site2)... [OK]\nStarting backup for domain domainN.com (siteN)... [OK]<\/pre>\n<p>Can&#8217;t be easier \ud83d\ude09 copy the code, save it and chmod +x  that&#8217;s all \ud83d\ude42<\/p>\n<pre lang=\"php\">#!\/usr\/bin\/php -q\n&lt;?\n\/\/ dirty code, no comments ;)\n$vhexport = '\/usr\/local\/bin\/vhexport';\n$sitelookup = '\/usr\/local\/bin\/sitelookup';\n\nif (count($argv) &lt;= 2) die(\"Usage: $argv[0] \/backup\/path domain1 domain2 ...domainN\\n\");\n\n$path = $argv[1]; $limit = (count($argv)-1);\nif (!is_dir($path)) die(\"$path doesn't exist, creat it first!\\n\");\nif (preg_match(\"\/\\\/$\/\",$path)) $path = substr($path,0,-1);\n\necho \"Building site's structure... \"; sleep(1);\n$ds = explode(\"\\n\",trim(`$sitelookup -a site_handle,domain`));\nif (!is_array($ds)) die(\"Server is empty!\\n\");\n\nforeach ($ds as $dlines) {\n  $tmpparts = explode(\",\",trim($dlines));\n  if (!is_array($tmpparts)) continue;\n  $domains[$tmpparts[1]] = $tmpparts[0];\n}\n\necho \"found \".count($ds).\" sites\\n\"; sleep(1);\necho \"Building backup for \".($limit-1).\" site(s)\\n\\n\";\n\nfor ($i=2;$i&lt;=$limit;$i++) {\n  $bdomain = $argv[$i];\n  $bsite = $domains[$bdomain];\n  if (!$bsite) { echo \"Looks like $bdomain has not a valid site_handle, aborting...\\n\"; continue; }\n  echo \"Starting backup for domain $bdomain ($bsite)... \";\n  $cmd = $vhexport . ' -s ' . $bsite . ' -U \"file:\/\/' . $path . '\/%(type)-%(name)\" -z';\n  \/\/echo \"\\n[debug] $cmd\\n\";\n  `$cmd`;\n  echo \"[OK]\\n\";\n}\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nothing but an easy to use backup script for Ensim (4.X-10.X) which uses vhexport, so yeah, it&#8217;s not fast, but I wrote it because sometimes you just need to backup 1 or a few sites and drop them somewhere \ud83d\ude1b You just need to type this: .\/backupsingle.php \/path\/to\/backup domain1.com domain2.com &#8230;domainN.com And you&#8217;ll see something [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,10,8],"tags":[25,13,32,33,15],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-code","category-ensim","category-linux","tag-backup","tag-centos","tag-ensim","tag-linux","tag-php"],"_links":{"self":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":2,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":151,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions\/151"}],"wp:attachment":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}