Created
October 24, 2015 17:55
-
-
Save aikar/c08e74770acfe58f62cc 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
<?php | |
class Server { | |
public static function backup($serverName) { | |
self::requireServerLocal($serverName); | |
Core::output('Starting backup for ' . $serverName); | |
$server = Config::get('servers', $serverName); | |
if (Server::isRunning($serverName)) { | |
Core::output('%-Server is running'); | |
Core::output('%-%-Forcing save'); | |
Server::send($serverName, 'save-all'); | |
Core::output('%-%-Disabling saving'); | |
Server::send($serverName, 'save-off'); | |
} | |
$hardPath = Config::get('server_base_path'); | |
$serverFolder = $server['folder']; | |
Core::startTimer('bup'); | |
$base = "$hardPath$serverFolder"; | |
$backupLoc = Config::get('backup_base_path') . "$serverFolder"; | |
$excludes = array( | |
'dynmap', 'lost+found', 'crash-reports', 'logs', 'gc.log*', 'timings', 'server.log' | |
); | |
$excludearg = ""; | |
foreach ($excludes as $ex) { | |
$excludearg .= ' --exclude ' . escapeshellarg("$base/$ex"); | |
} | |
Core::output(shell_exec("rdiff-backup $excludearg $base $backupLoc")); | |
Core::output('%-backup done, took ' . Core::getTimer('bup') . ' seconds'); | |
if (Server::isRunning($serverName)) { | |
Core::output('%-Server is running'); | |
Core::output('%-%-Enabling saving'); | |
Server::send($serverName, 'save-on'); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment