Nothing but an easy to use backup script for Ensim (4.X-10.X) which uses vhexport, so yeah, it’s not fast, but I wrote it because sometimes you just need to backup 1 or a few sites and drop them somewhere 😛
You just need to type this:
./backupsingle.php /path/to/backup domain1.com domain2.com ...domainN.com
And you’ll see something like this:
Building site's structure... found NN sites
Building backup for N site(s)
Starting backup for domain domain1.com (site1)... [OK]
Starting backup for domain domain2.com (site2)... [OK]
Starting backup for domain domainN.com (siteN)... [OK]
Can’t be easier 😉 copy the code, save it and chmod +x that’s all 🙂
#!/usr/bin/php -q
<?
// dirty code, no comments ;)
$vhexport = '/usr/local/bin/vhexport';
$sitelookup = '/usr/local/bin/sitelookup';
if (count($argv) <= 2) die("Usage: $argv[0] /backup/path domain1 domain2 ...domainN\n");
$path = $argv[1]; $limit = (count($argv)-1);
if (!is_dir($path)) die("$path doesn't exist, creat it first!\n");
if (preg_match("/\/$/",$path)) $path = substr($path,0,-1);
echo "Building site's structure... "; sleep(1);
$ds = explode("\n",trim(`$sitelookup -a site_handle,domain`));
if (!is_array($ds)) die("Server is empty!\n");
foreach ($ds as $dlines) {
$tmpparts = explode(",",trim($dlines));
if (!is_array($tmpparts)) continue;
$domains[$tmpparts[1]] = $tmpparts[0];
}
echo "found ".count($ds)." sites\n"; sleep(1);
echo "Building backup for ".($limit-1)." site(s)\n\n";
for ($i=2;$i<=$limit;$i++) {
$bdomain = $argv[$i];
$bsite = $domains[$bdomain];
if (!$bsite) { echo "Looks like $bdomain has not a valid site_handle, aborting...\n"; continue; }
echo "Starting backup for domain $bdomain ($bsite)... ";
$cmd = $vhexport . ' -s ' . $bsite . ' -U "file://' . $path . '/%(type)-%(name)" -z';
//echo "\n[debug] $cmd\n";
`$cmd`;
echo "[OK]\n";
}
?>