Skip to content

Instantly share code, notes, and snippets.

@diversen
Created May 2, 2016 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diversen/0c33e42d62bdd9b73cff4d9155f6a879 to your computer and use it in GitHub Desktop.
Save diversen/0c33e42d62bdd9b73cff4d9155f6a879 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
// Backup all sites in folder
// Extract back - remember -p flag in tar command
function getSites () {
$test = "/datadrive/www/event.smartpub.dk";
$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 && ./coscli.sh backup --full $dest/latest.tar.gz && ./coscli.sh db --dump-db-file $dest/latest.sql";
return $command;
}
$sites = getSites();
foreach ($sites as $site) {
$command = getCommand($site);
system($command);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment