Yes
![Smile :)](./images/smilies/icon_e_smile.gif)
[syntax=php] // backs up all worlds.
public function worlds(){
if (!$this->server->is_running() || !$this->server->plugin->ready){
return false;
}
$start = microtime(true);
$this->server->save_off();
$this->server->save_all(true);
$worlds = $this->server->plugin->get_worlds();
foreach ($worlds as $world => $folder){
shell_exec('cp -R ' . escapeshellarg($folder) . ' ' . escapeshellarg("{$GLOBALS['core_path']}/data/backups/worlds"));
}
$this->server->save_on();
$old_cwd = getcwd();
chdir("{$GLOBALS['core_path']}/data/backups/worlds/");
foreach ($worlds as $world => $folder){
shell_exec('tar -czf ' . escapeshellarg("{$world}_" . time() . ".tar.gz") . ' ' . escapeshellarg($folder));
shell_exec('rm -Rf ' . escapeshellarg($folder));
}
chdir($old_cwd);
$time_taken = round(microtime(true) - $start, 3);
$this->server->say('Backup completed in ' . $time_taken . ' seconds');
return $time_taken;
}[/syntax]
This is the method that does the world backup, there is also
[syntax=php] // removes any backups that are older than the configured time.
public function cleanup(){
$files = scandir("{$GLOBALS['core_path']}/data/backups/worlds");
unset($files[0], $files[1]);
foreach ($files as $file){
$full_path = "{$GLOBALS['core_path']}/data/backups/worlds/{$file}";
if (filectime($full_path) < (time() - ($GLOBALS['config']['backups']['max_map_backup_age'] * 3600))){
unlink($full_path);
}
}
}[/syntax]
which runs every hour or so to remove any old backups.
And finally
[syntax=php] // backs up the server set up.
public function server(){
}[/syntax]
Which I still need to make
![Wink ;)](./images/smilies/icon_e_wink.gif)