Minecraft Backup Script
Posted: Sun Dec 11, 2011 12:53 pm
Jacekk,
Can you show me your public servers backup script please.
Thanks,
SamzRulez(Sam)
Can you show me your public servers backup script please.
Thanks,
SamzRulez(Sam)
// 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; }This is the method that does the world backup, there is also
// 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); } } }which runs every hour or so to remove any old backups.
// backs up the server set up. public function server(){ }Which I still need to make
There are simpler ones around... http://www.google.co.uk/search?hl=en&q= ... kup+scirptSamzRulez wrote:wow thats confusing.
We don't need to know how to spell any more thanks to spell-check and googleSamzRulez wrote:You spelt it wrong lol.