Created
May 2, 2016 13:03
-
-
Save diversen/0c33e42d62bdd9b73cff4d9155f6a879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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