Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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