case 'backup': $carrier = db_prepare_input($_POST['carrier']); $fy_month = db_prepare_input($_POST['fy_month']); $fy_year = db_prepare_input($_POST['fy_year']); $conv_type = db_prepare_input($_POST['conv_type']); // set execution time limit to a large number to allow extra time if (ini_get('max_execution_time') < 20000) { set_time_limit(20000); } $backup = new backup(); $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $carrier . '/' . $fy_year . '/' . $fy_month . '/'; $backup->dest_dir = DIR_FS_MY_FILES . 'backups/'; switch ($conv_type) { case 'bz2': $backup->dest_file = 'ship_' . $carrier . '_' . $fy_year . $fy_month . '.tar.bz2'; if ($backup->make_bz2('dir')) { $error = true; } break; default: case 'zip': $backup->dest_file = 'ship_' . $carrier . '_' . $fy_year . $fy_month . '.zip'; if ($backup->make_zip('dir')) { $error = true; } break; } if (!$error) { gen_add_audit_log(GEN_DB_DATA_BACKUP, TABLE_AUDIT_LOG); $backup->download($backup->dest_dir, $backup->dest_file); // will not return if successful
$backup->db_filename = 'db-' . $_SESSION['company'] . '-' . date('Ymd'); $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/'; $backup->source_file = $backup->db_filename . '.sql'; $backup->dest_dir = DIR_FS_MY_FILES . 'backups/'; if (!($result = $backup->dump_db_table($db, 'all', 'both'))) { break; } // compress the company directory switch ($conv_type) { case 'bz2': if ($dl_type == 'file') { $backup->dest_file = $backup->db_filename . '.bz2'; } else { $backup->dest_file = 'bu-' . $_SESSION['company'] . '-' . date('Ymd') . '.tar.bz2'; } if ($backup->make_bz2($dl_type)) { $error = true; } @unlink($backup->source_dir . $backup->source_file); // delete db sql file break; case 'zip': if ($dl_type == 'file') { $backup->dest_file = $backup->db_filename . '.zip'; } else { $backup->dest_file = 'bu-' . $_SESSION['company'] . '-' . date('Ymd') . '.zip'; } if ($backup->make_zip($dl_type)) { $error = true; } @unlink($backup->source_dir . $backup->source_file);