Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
scripts
File Content:
DailyBackup_Admin.php
<?php require('/etc/sentora/panel/cnf/database.php'); include('/etc/sentora/panel/dryden/db/driver.class.php'); include('/etc/sentora/panel/dryden/debug/logger.class.php'); include('/etc/sentora/panel/dryden/runtime/dataobject.class.php'); include('/etc/sentora/panel/dryden/runtime/hook.class.php'); include('/etc/sentora/panel/dryden/sys/versions.class.php'); include('/etc/sentora/panel/dryden/ctrl/options.class.php'); include('/etc/sentora/panel/dryden/fs/director.class.php'); include('/etc/sentora/panel/dryden/fs/filehandler.class.php'); include('/etc/sentora/panel/inc/dbc.inc.php'); include('/etc/sentora/panel/dryden/ui/module.class.php'); // include('cnf/db.php'); $z_db_user = $user; $z_db_pass = $pass; $z_db_host = $host; $z_db_name = $dbname; try { $dsn = "mysql:dbname=$dbname;$ovi_socket_path"; $zdbh = new db_driver($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); $zdbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { } echo fs_filehandler::NewLine() . "START Backup Config." . fs_filehandler::NewLine(); if (ui_module::CheckModuleEnabled('Backup Config')) { echo "Backup Config module ENABLED..." . fs_filehandler::NewLine(); // Schedule daily backups are enabled... if (strtolower(ctrl_options::GetSystemOption('schedule_bu')) == "true") { runtime_hook::Execute('OnBeforeScheduleBackup'); echo "Backup Scheduling enabled - Backing up all enabled client files now..." . fs_filehandler::NewLine(); // Get all accounts $bsql = "SELECT * FROM x_accounts WHERE ac_enabled_in=1 AND ac_deleted_ts IS NULL"; $numrows = $zdbh->query($bsql); if ($numrows->fetchColumn() <> 0) { $bsql = $zdbh->prepare($bsql); $bsql->execute(); while ($rowclients = $bsql->fetch()) { echo "Backing up client folder: " . $rowclients['ac_user_vc'] . fs_filehandler::NewLine(); // User loop $username = $rowclients['ac_user_vc']; $userid = $rowclients['ac_id_pk']; $homedir = ctrl_options::GetSystemOption('hosted_dir') . $username; $backupname = $username . "_" . date("M-d-Y_hms", time()); $dbstamp = date("dmy_Gi", time()); // We now see what the OS is before we work out what compression command to use.. if (sys_versions::ShowOSPlatformVersion() == "Windows") { $resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " a -tzip -y-r " . ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip " . $homedir . "./* -x ./backups/\* 2>&1")); } else {//cd /var/sentora/hostdata/zadmin/; zip -r backups/backup.zip public_html/ $resault = exec("cd " . $homedir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " -r9 " . ctrl_options::GetSystemOption('temp_dir') . $backupname . " ./* -x ./backups/\* 2>&1"); @chmod(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip", 0777); } // Now lets backup all MySQL datbases for the user and add them to the archive... $sql = "SELECT COUNT(*) FROM x_mysql_databases WHERE my_acc_fk=" . $userid . " AND my_deleted_ts IS NULL"; if ($numrows = $zdbh->query($sql)) { if ($numrows->fetchColumn() <> 0) { $sql = $zdbh->prepare("SELECT * FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL"); $sql->bindParam(':userid', $userid); $sql->execute(); while ($row_mysql = $sql->fetch()) { $bkcommand = ctrl_options::GetSystemOption('mysqldump_exe') . " -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-db " . $row_mysql['my_name_vc'] . " > " . ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"; passthru($bkcommand); // Add it to the ZIP archive... if (sys_versions::ShowOSPlatformVersion() == "Windows") { $resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " u " . ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip " . ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql")); } else { $resault = exec("cd " . ctrl_options::GetSystemOption('temp_dir') . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " " . ctrl_options::GetSystemOption('temp_dir') . $backupname . " " . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"); } $unlink_sql_file=ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"; if(file_exists($unlink_sql_file) && !is_dir($unlink_sql_file) && $row_mysql['my_name_vc']!="") unlink($unlink_sql_file); } } } // We have the backup now lets output it to disk or download if (file_exists(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip")) { // Copy Backup to user home directory... $backupdir = $homedir . "/backups/"; if (!is_dir($backupdir)) { mkdir($backupdir, 0777, TRUE); } copy(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip", $backupdir . $backupname . ".zip"); $unlink_zip_file=ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip"; if(file_exists($unlink_zip_file) && !is_dir($unlink_zip_file) && $backupname !="" ) unlink($unlink_zip_file); fs_director::SetFileSystemPermissions($backupdir . $backupname . ".zip", 0777); echo $backupdir . $backupname . ".zip" . fs_filehandler::NewLine(); } } } runtime_hook::Execute('OnAfterScheduleBackup'); echo "Backup Schedule COMPLETE..." . fs_filehandler::NewLine(); } // Purge backups are enabled.... if (strtolower(ctrl_options::GetSystemOption('purge_bu')) == "true") { echo fs_filehandler::NewLine() . "Backup Purging enabled - Purging backups older than " . ctrl_options::GetSystemOption('purge_date') . " days..." . fs_filehandler::NewLine(); runtime_hook::Execute('OnBeforePurgeBackup'); clearstatcache(); // Get all accounts $bsql = "SELECT * FROM x_accounts WHERE ac_enabled_in=1 AND ac_deleted_ts IS NULL"; $numrows = $zdbh->query($bsql); if ($numrows->fetchColumn() <> 0) { $purge_date = ctrl_options::GetSystemOption('purge_date'); $bsql = $zdbh->prepare($bsql); $bsql->execute(); echo "[FILE][PURGE_DATE][FILE_DATE][ACTION]" . fs_filehandler::NewLine(); while ($rowclients = $bsql->fetch()) { $username = $rowclients['ac_user_vc']; $backupdir = ctrl_options::GetSystemOption('hosted_dir') . $username . "/backups/"; if ($handle = @opendir($backupdir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $filetime = @filemtime($backupdir . $file); if ($filetime == NULL) { $filetime = @filemtime(utf8_decode($backupdir . $file)); } $filetime = floor((time() - $filetime) / 86400); echo "" . $file . " - " . $purge_date . " - " . $filetime . ""; if ($purge_date < $filetime) { //delete the file echo " - Deleting file..." . fs_filehandler::NewLine(); if(file_exists("$backupdir . $file") && trim($username)!="") unlink($backupdir . $file); } else { echo " - Skipping file..." . fs_filehandler::NewLine(); } } } } } } echo "Backup Purging COMPLETE..." . fs_filehandler::NewLine(); runtime_hook::Execute('OnAfterPurgeBackup'); } // Clean temp backups.... echo fs_filehandler::NewLine() . "Purging backups from temp folder..." . fs_filehandler::NewLine(); clearstatcache(); echo "[FILE][PURGE_DATE][FILE_DATE][ACTION]" . fs_filehandler::NewLine(); $temp_dir = ctrl_options::GetSystemOption('sentora_root') . "/modules/backupmgr/temp/"; if ($handle = @opendir($temp_dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $filetime = @filemtime($temp_dir . $file); if ($filetime == NULL) { $filetime = @filemtime(utf8_decode($temp_dir . $file)); } $filetime = floor((time() - $filetime) / 86400); echo "" . $file . " - " . $purge_date . " - " . $filetime . ""; if (1 <= $filetime) { //delete the file echo " - Deleting file..." . fs_filehandler::NewLine(); if(file_exists($temp_dir . $file) && !is_dir($temp_dir . $file)) unlink($temp_dir . $file); } else { echo " - Skipping file..." . fs_filehandler::NewLine(); } } } } } else { echo "Backup Config module DISABLED...nothing to do." . fs_filehandler::NewLine(); } echo "END Backup Config." . fs_filehandler::NewLine(); ?>
Edit
Download
Unzip
Chmod
Delete