Jacekk,
Can you show me your public servers backup script please.
Thanks,
SamzRulez(Sam)
Minecraft Backup Script
Minecraft Backup Script
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Minecraft Backup Script
Yes
[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
[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
Re: Minecraft Backup Script
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:34 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Minecraft Backup Script
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:34 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Minecraft Backup Script
SamzRulez wrote:wow thats confusing.
There are simpler ones around... http://www.google.co.uk/search?hl=en&q= ... kup+scirpt
Re: Minecraft Backup Script
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:34 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Minecraft Backup Script
SamzRulez wrote:You spelt it wrong lol.
We don't need to know how to spell any more thanks to spell-check and google