Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env php
// Backup all sites in folder
// Extract back - remember -p flag in tar command
function getSites () {
$test = "/datadrive/www/";
$real = "/datadrive/www/*";
$dirs = glob($test, GLOB_ONLYDIR);
return $dirs;
function getCommand ($site) {
$dest_site = basename($site);
$dest = "/home/smartpub/backup/$dest_site";
exec("sudo mkdir -p $dest");
$command = "cd $site && ./ backup --full $dest/latest.tar.gz && ./ db --dump-db-file $dest/latest.sql";
return $command;
$sites = getSites();
foreach ($sites as $site) {
$command = getCommand($site);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment