Task = new Task($System); $this->Id = $Id; $DbResult = $this->Database->query('SELECT * FROM `Backup` WHERE `Id`='.$Id); if($DbResult->num_rows > 0) $this->Backup = $DbResult->fetch_assoc(); else $this->Backup = array(); } function Restore() { $ServerId = $this->Backup['Server']; $this->Task->Add('Obnovení databáze', array( 'php www/shell.php ServerLock '.$ServerId, 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos', 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters', 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd', 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2', 'mkdir temp/wowhosting', 'tar -xjf backup/wowhosting-'.$this->Id.'.tar.bz2 -C temp', 'mysql --user=server'.$ServerId.' --password=server'.$ServerId.' server'.$ServerId.'_characters < temp/wowhosting/characters.sql', 'mysql --user=server'.$ServerId.' --password=server'.$ServerId.' server'.$ServerId.'_realmd < temp/wowhosting/realmd.sql', 'mysql --user=server'.$ServerId.' --password=server'.$ServerId.' server'.$ServerId.'_mangos < temp/wowhosting/mangos.sql', 'mysql --user=server'.$ServerId.' --password=server'.$ServerId.' server'.$ServerId.'_scriptdev2 < temp/wowhosting/scriptdev2.sql', 'rm -rf temp/wowhosting', 'php www/shell.php ServerDatabaseChange '.$ServerId.' '.$this->Backup['Database'], 'php www/shell.php ServerUnLock '.$ServerId, )); return('Úloha obnovení databáze ze zálohy zařazena do fronty.'); } function Create($ServerId) { $Server = new Server($this->System, $ServerId); $Description = 'MaNGOS r'.$Server->Server['Database']['Emulator']['Revision'].', UDB r'.$Server->Server['Database']['Revision'].', SD2 r'.$Server->Server['Database']['ScriptDev2Revision'].', Client '.$Server->Server['Database']['Emulator']['Client']['Version']; $this->Database->insert('Backup', array('Server' => $ServerId, 'Time' => 'NOW()', 'Description' => $Description, 'Lock' => 1, 'Database' => $Server->Server['Database']['Id'])); $this->Id = $this->Database->insert_id; $this->Task->Add('Záloha databáze serveru', array( 'php www/shell.php ServerLock '.$ServerId, 'mkdir temp/wowhosting', 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_characters > temp/wowhosting/characters.sql', 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_realmd > temp/wowhosting/realmd.sql', 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_mangos > temp/wowhosting/mangos.sql', 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_scriptdev2 > temp/wowhosting/scriptdev2.sql', 'cd temp', 'tar -c -j wowhosting > ../backup/wowhosting-'.$this->Id.'.tar.bz2', 'rm -rf wowhosting', 'cd ..', 'php www/shell.php BackupUnLock '.$this->Id, 'php www/shell.php ServerUnLock '.$ServerId, )); return('Úloha zálohování byla zařazena do fronty.'); } function Lock() { $this->Database->update('Backup', 'Id='.$this->Id, array('Lock' => 1)); } function UnLock() { $this->Database->update('Backup', 'Id='.$this->Id, array('Lock' => 0)); } }