diff --git a/app/backup/resources/classes/backup.php b/app/backup/resources/classes/backup.php new file mode 100644 index 0000000000..a3357b91cf --- /dev/null +++ b/app/backup/resources/classes/backup.php @@ -0,0 +1,80 @@ + + Copyright (C) 2010-2014 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the backup class + if (!class_exists('backup')) { + class backup { + //variables + public $result; + public $domain_uuid; + + public function command($type, $format) { + global $db; + if ($type == "backup") { + $backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp'; + $backup_file = 'backup_'.date('Ymd_His').'.'.$file_format; + if (count($_SESSION['backup']['path']) > 0) { + //determine compression method + switch ($format) { + case "rar" : $cmd = 'rar a -ow -r '; break; + case "zip" : $cmd = 'zip -r '; break; + case "tbz" : $cmd = 'tar -jvcf '; break; + default : $cmd = 'tar -zvcf '; + } + $cmd .= $backup_path.'/'.$backup_file.' '; + foreach ($_SESSION['backup']['path'] as $value) { + $cmd .= $value.' '; + } + return $cmd; + } + else { + return false; + } + } + if ($type == "restore") { + $backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp'; + $backup_file = 'backup_'.date('Ymd_His').'.'.$file_format; + if (count($_SESSION['backup']['path']) > 0) { + switch ($format) { + case "rar" : $cmd = 'rar x -ow -o+ '.$backup_path.'/'.$backup_file.' /'; break; + case "zip" : $cmd = 'umask 755; unzip -o -qq -X -K '.$backup_path.'/'.$backup_file.' -d /'; break; + case "tbz" : $cmd = 'tar -xvpjf '.$backup_path.'/'.$backup_file.' -C /'; break; + case "tgz" : $cmd = 'tar -xvpzf '.$backup_path.'/'.$backup_file.' -C /'; break; + default: $valid_format = false; + } + return $cmd; + } + else { + return false; + } + } + } + + } + } + +?> \ No newline at end of file