Version Description
- Added setting for Send Mail type.
- Optimize Memory usage again
- Fixed Bug that cron not work
Download this release
Release Info
| Developer | danielhuesken |
| Plugin | |
| Version | 0.6.1 |
| Comparing to | |
| See all releases | |
Code changes from version 0.6.0 to 0.6.1
- app/dojob/after.php +12 -16
- app/dojob/bevore.php +1 -1
- app/dojob/db.php +41 -43
- app/dojob/destination-mail.php +6 -2
- app/dojob/file.php +9 -15
- app/functions.php +31 -7
- app/options-edit.php +2 -2
- app/options-save.php +6 -1
- app/options-settings.php +31 -0
- backwpup.php +2 -2
- readme.txt +8 -3
app/dojob/after.php
CHANGED
|
@@ -2,31 +2,26 @@
|
|
| 2 |
//Delete old Logs/Backupfiles
|
| 3 |
if (!empty($jobs[$jobid]['maxbackups'])) {
|
| 4 |
BackWPupFunctions::joblog($logtime,__('Delete old backup files...','backwpup'));
|
| 5 |
-
$
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
if ($
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
$countdelbackups++;
|
| 15 |
-
}
|
| 16 |
-
$wpdb->query("DELETE FROM ".$wpdb->backwpup_logs." WHERE logtime=".$logs[$i]['logtime']);
|
| 17 |
-
$countdellogs++;
|
| 18 |
}
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
}
|
| 21 |
if ($countdelbackups>0)
|
| 22 |
BackWPupFunctions::joblog($logtime,$countdelbackups.' '.__('old backup files deleted!!!','backwpup'));
|
| 23 |
if ($countdellogs>0)
|
| 24 |
BackWPupFunctions::joblog($logtime,$countdellogs.' '.__('old logs deleted!!!','backwpup'));
|
| 25 |
-
//clean vars
|
| 26 |
-
unset($logs);
|
| 27 |
}
|
| 28 |
|
| 29 |
-
|
| 30 |
if (is_file($backupfile)) {
|
| 31 |
BackWPupFunctions::joblog($logtime,sprintf(__('Backup zip filesize is %1s','backwpup'),BackWPupFunctions::formatBytes(filesize($backupfile))));
|
| 32 |
}
|
|
@@ -46,6 +41,7 @@ $jobs[$jobid]['lastrun']=$jobs[$jobid]['starttime'];
|
|
| 46 |
$jobs[$jobid]['lastruntime']=$jobs[$jobid]['stoptime']-$jobs[$jobid]['starttime'];
|
| 47 |
$jobs[$jobid]['scheduletime']=wp_next_scheduled('backwpup_cron',array('jobid'=>$jobid));
|
| 48 |
update_option('backwpup_jobs',$jobs); //Save Settings
|
|
|
|
| 49 |
//Write backupfile und worktime to log
|
| 50 |
$wpdb->update( $wpdb->backwpup_logs, array( 'worktime' => $jobs[$jobid]['lastruntime'], 'backupfile' => mysql_real_escape_string($backupfile)), array( 'logtime' => $logtime ));
|
| 51 |
ob_end_flush();
|
| 2 |
//Delete old Logs/Backupfiles
|
| 3 |
if (!empty($jobs[$jobid]['maxbackups'])) {
|
| 4 |
BackWPupFunctions::joblog($logtime,__('Delete old backup files...','backwpup'));
|
| 5 |
+
$counter=0;$countdelbackups=0;$countdellogs=0;
|
| 6 |
+
$result=mysql_query("SELECT * FROM ".$wpdb->backwpup_logs." ORDER BY logtime DESC");
|
| 7 |
+
while ($logs = mysql_fetch_assoc($result)) {
|
| 8 |
+
if (!empty($logs['backupfile']) or in_array($jobs[$jobid]['type'],$logonlytyps))
|
| 9 |
+
$counter++;
|
| 10 |
+
if ($counter>=$jobs[$jobid]['maxbackups']) {
|
| 11 |
+
if (is_file($logs['backupfile'])) {
|
| 12 |
+
unlink($logs['backupfile']);
|
| 13 |
+
$countdelbackups++;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
+
$wpdb->query("DELETE FROM ".$wpdb->backwpup_logs." WHERE logtime=".$logs['logtime']);
|
| 16 |
+
$countdellogs++;
|
| 17 |
}
|
| 18 |
}
|
| 19 |
if ($countdelbackups>0)
|
| 20 |
BackWPupFunctions::joblog($logtime,$countdelbackups.' '.__('old backup files deleted!!!','backwpup'));
|
| 21 |
if ($countdellogs>0)
|
| 22 |
BackWPupFunctions::joblog($logtime,$countdellogs.' '.__('old logs deleted!!!','backwpup'));
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
|
|
|
|
| 25 |
if (is_file($backupfile)) {
|
| 26 |
BackWPupFunctions::joblog($logtime,sprintf(__('Backup zip filesize is %1s','backwpup'),BackWPupFunctions::formatBytes(filesize($backupfile))));
|
| 27 |
}
|
| 41 |
$jobs[$jobid]['lastruntime']=$jobs[$jobid]['stoptime']-$jobs[$jobid]['starttime'];
|
| 42 |
$jobs[$jobid]['scheduletime']=wp_next_scheduled('backwpup_cron',array('jobid'=>$jobid));
|
| 43 |
update_option('backwpup_jobs',$jobs); //Save Settings
|
| 44 |
+
BackWPupFunctions::joblog($logtime,sprintf(__('Backup Excution time %1s sec.','backwpup'),$jobs[$jobid]['lastruntime']));
|
| 45 |
//Write backupfile und worktime to log
|
| 46 |
$wpdb->update( $wpdb->backwpup_logs, array( 'worktime' => $jobs[$jobid]['lastruntime'], 'backupfile' => mysql_real_escape_string($backupfile)), array( 'logtime' => $logtime ));
|
| 47 |
ob_end_flush();
|
app/dojob/bevore.php
CHANGED
|
@@ -38,7 +38,7 @@ if (!ini_get('safe_mode') or strtolower(ini_get('safe_mode'))=='off' or ini_get(
|
|
| 38 |
}
|
| 39 |
|
| 40 |
//Look for and Crate Temp dir and secure
|
| 41 |
-
BackWPupFunctions::joblog($logtime,sprintf(__('Temp dir is %1$s.','backwpup'),get_temp_dir().'backwpup'));
|
| 42 |
|
| 43 |
if (!is_dir(BackWPupFunctions::get_temp_dir().'backwpup')) {
|
| 44 |
if (!mkdir(BackWPupFunctions::get_temp_dir().'backwpup',0777,true)) {
|
| 38 |
}
|
| 39 |
|
| 40 |
//Look for and Crate Temp dir and secure
|
| 41 |
+
BackWPupFunctions::joblog($logtime,sprintf(__('Temp dir is %1$s.','backwpup'),BackWPupFunctions::get_temp_dir().'backwpup'));
|
| 42 |
|
| 43 |
if (!is_dir(BackWPupFunctions::get_temp_dir().'backwpup')) {
|
| 44 |
if (!mkdir(BackWPupFunctions::get_temp_dir().'backwpup',0777,true)) {
|
app/dojob/db.php
CHANGED
|
@@ -1,65 +1,62 @@
|
|
| 1 |
<?PHP
|
| 2 |
BackWPupFunctions::joblog($logtime,__('Run Database Backup...','backwpup'));
|
| 3 |
|
| 4 |
-
function dump_table($table,$status) {
|
| 5 |
global $wpdb,$logtime;
|
| 6 |
$table = str_replace("�", "��", $table); //esc table name
|
| 7 |
|
| 8 |
// create dump
|
| 9 |
-
$
|
| 10 |
-
$
|
| 11 |
-
$
|
| 12 |
-
$
|
| 13 |
-
$
|
| 14 |
-
$
|
| 15 |
-
$
|
| 16 |
//Dump the table structure
|
| 17 |
-
$result
|
| 18 |
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
| 19 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $sqlerr->last_query));
|
| 20 |
return false;
|
| 21 |
}
|
| 22 |
-
$
|
| 23 |
-
$
|
| 24 |
-
$
|
| 25 |
|
| 26 |
//take data of table
|
| 27 |
-
|
| 28 |
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
| 29 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $sqlerr->last_query));
|
| 30 |
return false;
|
| 31 |
}
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
-
}
|
| 54 |
-
// make data dump
|
| 55 |
-
$dump .= "INSERT INTO `".$table."` ( ".implode(", ",$keys)." )\n\tVALUES ( ".implode(", ",$values)." );\n";
|
| 56 |
}
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
$dump.= "UNLOCK TABLES;\n";
|
| 60 |
}
|
| 61 |
-
$
|
| 62 |
-
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
|
|
@@ -110,8 +107,8 @@ if (sizeof($tables)>0) {
|
|
| 110 |
//make table dumps
|
| 111 |
foreach($tables as $table) {
|
| 112 |
BackWPupFunctions::joblog($logtime,__('Database table to Backup: ','backwpup').' '.$table);
|
| 113 |
-
BackWPupFunctions::needfreememory(($status[$table]['Data_length']+$status[$table]['Index_length'])*
|
| 114 |
-
fwrite($file, dump_table($table,$status[$table]));
|
| 115 |
}
|
| 116 |
//for better import with mysql client
|
| 117 |
fwrite($file, "\n");
|
|
@@ -135,6 +132,7 @@ if (sizeof($tables)>0) {
|
|
| 135 |
BackWPupFunctions::joblog($logtime,__('Database backup done!','backwpup'));
|
| 136 |
|
| 137 |
if ($jobs[$jobid]['type']=='DB' and is_file(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')) {
|
|
|
|
| 138 |
BackWPupFunctions::joblog($logtime,__('Database file size:','backwpup').' '.BackWPupFunctions::formatBytes(filesize(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')));
|
| 139 |
BackWPupFunctions::joblog($logtime,__('Create Zip file from dump...','backwpup'));
|
| 140 |
$zipbackupfile = new PclZip($backupfile);
|
| 1 |
<?PHP
|
| 2 |
BackWPupFunctions::joblog($logtime,__('Run Database Backup...','backwpup'));
|
| 3 |
|
| 4 |
+
function dump_table($table,$status,$file) {
|
| 5 |
global $wpdb,$logtime;
|
| 6 |
$table = str_replace("�", "��", $table); //esc table name
|
| 7 |
|
| 8 |
// create dump
|
| 9 |
+
fwrite($file, "\n");
|
| 10 |
+
fwrite($file, "--\n");
|
| 11 |
+
fwrite($file, "-- Table structure for table $table\n");
|
| 12 |
+
fwrite($file, "--\n\n");
|
| 13 |
+
fwrite($file, "DROP TABLE IF EXISTS `" . $table . "`;\n");
|
| 14 |
+
fwrite($file, "/*!40101 SET @saved_cs_client = @@character_set_client */;\n");
|
| 15 |
+
fwrite($file, "/*!40101 SET character_set_client = latin1 */;\n");
|
| 16 |
//Dump the table structure
|
| 17 |
+
$result=mysql_query("SHOW CREATE TABLE `".$table."`");
|
| 18 |
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
| 19 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $sqlerr->last_query));
|
| 20 |
return false;
|
| 21 |
}
|
| 22 |
+
$tablestruc=mysql_fetch_assoc($result);
|
| 23 |
+
fwrite($file, $tablestruc['Create Table']."\n");
|
| 24 |
+
fwrite($file, "/*!40101 SET character_set_client = @saved_cs_client */;\n");
|
| 25 |
|
| 26 |
//take data of table
|
| 27 |
+
$result=mysql_query("SELECT * FROM `".$table."`");
|
| 28 |
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
| 29 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $sqlerr->last_query));
|
| 30 |
return false;
|
| 31 |
}
|
| 32 |
+
|
| 33 |
+
fwrite($file, "--\n");
|
| 34 |
+
fwrite($file, "-- Dumping data for table $table\n");
|
| 35 |
+
fwrite($file, "--\n\n");
|
| 36 |
+
fwrite($file, "LOCK TABLES `".$table."` WRITE;\n\n");
|
| 37 |
+
if ($status['Engine']=='MyISAM')
|
| 38 |
+
fwrite($file, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
|
| 39 |
+
|
| 40 |
+
while ($data = mysql_fetch_assoc($result)) {
|
| 41 |
+
$keys = array();
|
| 42 |
+
$values = array();
|
| 43 |
+
foreach($data as $key => $value) {
|
| 44 |
+
$keys[] = "`".str_replace("�", "��", $key)."`"; // Add key to key list
|
| 45 |
+
if($value === NULL) // Make Value NULL to string NULL
|
| 46 |
+
$value = "NULL";
|
| 47 |
+
elseif($value === "" or $value === false) // if empty or false Value make "" as Value
|
| 48 |
+
$value = '""';
|
| 49 |
+
elseif(!is_numeric($value)) //is value not numeric esc
|
| 50 |
+
$value = "\"".mysql_real_escape_string($value)."\"";
|
| 51 |
|
| 52 |
+
$values[] = $value;
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
+
// make data dump
|
| 55 |
+
fwrite($file, "INSERT INTO `".$table."` ( ".implode(", ",$keys)." )\n\tVALUES ( ".implode(", ",$values)." );\n");
|
|
|
|
| 56 |
}
|
| 57 |
+
if ($status['Engine']=='MyISAM')
|
| 58 |
+
fwrite($file, "/*!40000 ALTER TABLE ".$table." ENABLE KEYS */;\n");
|
| 59 |
+
fwrite($file, "UNLOCK TABLES;\n");
|
| 60 |
}
|
| 61 |
|
| 62 |
|
| 107 |
//make table dumps
|
| 108 |
foreach($tables as $table) {
|
| 109 |
BackWPupFunctions::joblog($logtime,__('Database table to Backup: ','backwpup').' '.$table);
|
| 110 |
+
BackWPupFunctions::needfreememory(($status[$table]['Data_length']+$status[$table]['Index_length'])*1.3); //get mor memory if needed
|
| 111 |
+
fwrite($file, dump_table($table,$status[$table],$file));
|
| 112 |
}
|
| 113 |
//for better import with mysql client
|
| 114 |
fwrite($file, "\n");
|
| 132 |
BackWPupFunctions::joblog($logtime,__('Database backup done!','backwpup'));
|
| 133 |
|
| 134 |
if ($jobs[$jobid]['type']=='DB' and is_file(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')) {
|
| 135 |
+
BackWPupFunctions::needfreememory(8388608); //8MB free memory for zip
|
| 136 |
BackWPupFunctions::joblog($logtime,__('Database file size:','backwpup').' '.BackWPupFunctions::formatBytes(filesize(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')));
|
| 137 |
BackWPupFunctions::joblog($logtime,__('Create Zip file from dump...','backwpup'));
|
| 138 |
$zipbackupfile = new PclZip($backupfile);
|
app/dojob/destination-mail.php
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
<?php
|
| 2 |
if (!empty($jobs[$jobid]['mailaddress'])) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
BackWPupFunctions::joblog($logtime,__('Sendig mail...','backwpup'));
|
| 4 |
if (is_file($backupfile)) {
|
| 5 |
if (filesize($backupfile)<20971520) {
|
| 6 |
$mailfiles[0]=$backupfile;
|
| 7 |
-
if (!BackWPupFunctions::needfreememory(filesize($backupfile)*3+
|
| 8 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Out of Memory for sending Backup Archive by mail','backwpup'));
|
| 9 |
unset($mailfiles);
|
| 10 |
}
|
|
@@ -20,7 +24,7 @@ if (!empty($jobs[$jobid]['mailaddress'])) {
|
|
| 20 |
if (wp_mail($jobs[$jobid]['mailaddress'],__('BackWPup Job:','backwpup').' '.$jobs[$jobid]['name'],$wpdb->get_var("SELECT log FROM ".$wpdb->backwpup_logs." WHERE logtime=".$logtime),'',$mailfiles)) {
|
| 21 |
BackWPupFunctions::joblog($logtime,__('Mail send!!!','backwpup'));
|
| 22 |
} else {
|
| 23 |
-
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Can not send mail
|
| 24 |
}
|
| 25 |
}
|
| 26 |
//clean vars
|
| 1 |
<?php
|
| 2 |
if (!empty($jobs[$jobid]['mailaddress'])) {
|
| 3 |
+
//maillig method
|
| 4 |
+
add_action('phpmailer_init', array('BackWPupFunctions', 'use_mail_method'));
|
| 5 |
+
global $phpmailer;
|
| 6 |
+
|
| 7 |
BackWPupFunctions::joblog($logtime,__('Sendig mail...','backwpup'));
|
| 8 |
if (is_file($backupfile)) {
|
| 9 |
if (filesize($backupfile)<20971520) {
|
| 10 |
$mailfiles[0]=$backupfile;
|
| 11 |
+
if (!BackWPupFunctions::needfreememory(filesize($backupfile)*3+50554432)) {
|
| 12 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Out of Memory for sending Backup Archive by mail','backwpup'));
|
| 13 |
unset($mailfiles);
|
| 14 |
}
|
| 24 |
if (wp_mail($jobs[$jobid]['mailaddress'],__('BackWPup Job:','backwpup').' '.$jobs[$jobid]['name'],$wpdb->get_var("SELECT log FROM ".$wpdb->backwpup_logs." WHERE logtime=".$logtime),'',$mailfiles)) {
|
| 25 |
BackWPupFunctions::joblog($logtime,__('Mail send!!!','backwpup'));
|
| 26 |
} else {
|
| 27 |
+
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Can not send mail:','backwpup').' '.$phpmailer->ErrorInfo);
|
| 28 |
}
|
| 29 |
}
|
| 30 |
//clean vars
|
app/dojob/file.php
CHANGED
|
@@ -11,7 +11,6 @@
|
|
| 11 |
return false;
|
| 12 |
if( ! $levels )
|
| 13 |
return false;
|
| 14 |
-
$files = array();
|
| 15 |
if ( $dir = @opendir( $folder ) ) {
|
| 16 |
while (($file = readdir( $dir ) ) !== false ) {
|
| 17 |
if ( in_array($file, array('.', '..','.svn') ) )
|
|
@@ -25,12 +24,10 @@
|
|
| 25 |
if (!$backwpup_jobs['backupplugins'] and false !== stripos($folder.'/'.$file,str_replace('\\','/',WP_PLUGIN_DIR)))
|
| 26 |
continue;
|
| 27 |
if ( is_dir( $folder . '/' . $file ) ) {
|
| 28 |
-
$
|
| 29 |
-
if( $files2 )
|
| 30 |
-
$files = array_merge($files, $files2 );
|
| 31 |
} elseif (is_file( $folder . '/' . $file )) {
|
| 32 |
if (is_readable($folder . '/' . $file)) {
|
| 33 |
-
$files
|
| 34 |
$filezise=filesize($folder . '/' . $file);
|
| 35 |
$backwpup_allfilezise=$backwpup_allfilezise+$filezise;
|
| 36 |
BackWPupFunctions::joblog($logtime,__('File to Backup:','backwpup').' '.$folder . '/' . $file.' '.BackWPupFunctions::formatBytes($filezise));
|
|
@@ -43,12 +40,12 @@
|
|
| 43 |
}
|
| 44 |
}
|
| 45 |
@closedir( $dir );
|
| 46 |
-
return
|
| 47 |
}
|
| 48 |
|
| 49 |
|
| 50 |
//Make filelist
|
| 51 |
-
$backwupu_exclude=array(); $dirinclude=array(); $allfilezise=''; $filelist=
|
| 52 |
|
| 53 |
if (!empty($jobs[$jobid]['fileexclude']))
|
| 54 |
$backwupu_exclude=split(',',$jobs[$jobid]['fileexclude']);
|
|
@@ -75,27 +72,26 @@
|
|
| 75 |
if (is_array($dirinclude)) {
|
| 76 |
foreach($dirinclude as $dirincludevalue) {
|
| 77 |
if (is_dir($dirincludevalue))
|
| 78 |
-
$filelist
|
| 79 |
}
|
| 80 |
}
|
| 81 |
-
|
| 82 |
|
| 83 |
-
if (
|
| 84 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('No files to Backup','backwpup'));
|
| 85 |
unset($filelist); //clean vars
|
| 86 |
} else {
|
| 87 |
BackWPupFunctions::joblog($logtime,__('Size off all files:','backwpup').' '.BackWPupFunctions::formatBytes($backwpup_allfilezise));
|
| 88 |
}
|
| 89 |
|
| 90 |
-
BackWPupFunctions::needfreememory(33554432);
|
| 91 |
-
|
| 92 |
//Create Zip File
|
| 93 |
-
if (
|
|
|
|
| 94 |
BackWPupFunctions::joblog($logtime,__('Create Backup Zip file...','backwpup'));
|
| 95 |
$zipbackupfile = new PclZip($backupfile);
|
| 96 |
if (0==$zipbackupfile -> create($filelist,PCLZIP_OPT_REMOVE_PATH,str_replace('\\','/',ABSPATH),PCLZIP_OPT_ADD_TEMP_FILE_ON)) {
|
| 97 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Zip file create:','backwpup').' '.$zipbackupfile->errorInfo(true));
|
| 98 |
}
|
|
|
|
| 99 |
if ($jobs[$jobid]['type']=='DB+FILE') {
|
| 100 |
BackWPupFunctions::joblog($logtime,__('Database file size:','backwpup').' '.BackWPupFunctions::formatBytes(filesize(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')));
|
| 101 |
BackWPupFunctions::joblog($logtime,__('Add Database dump to Backup Zip file...','backwpup'));
|
|
@@ -103,9 +99,7 @@
|
|
| 103 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Zip file create Add Database dump:','backwpup').' '.$zipbackupfile->errorInfo(true));
|
| 104 |
}
|
| 105 |
}
|
| 106 |
-
//clean vars
|
| 107 |
unset($zipbackupfile);
|
| 108 |
-
unset($filelist);
|
| 109 |
BackWPupFunctions::joblog($logtime,__('Backup Zip file create done!','backwpup'));
|
| 110 |
}
|
| 111 |
|
| 11 |
return false;
|
| 12 |
if( ! $levels )
|
| 13 |
return false;
|
|
|
|
| 14 |
if ( $dir = @opendir( $folder ) ) {
|
| 15 |
while (($file = readdir( $dir ) ) !== false ) {
|
| 16 |
if ( in_array($file, array('.', '..','.svn') ) )
|
| 24 |
if (!$backwpup_jobs['backupplugins'] and false !== stripos($folder.'/'.$file,str_replace('\\','/',WP_PLUGIN_DIR)))
|
| 25 |
continue;
|
| 26 |
if ( is_dir( $folder . '/' . $file ) ) {
|
| 27 |
+
$files .= ",".backwpup_list_files( $folder . '/' . $file, $levels - 1);
|
|
|
|
|
|
|
| 28 |
} elseif (is_file( $folder . '/' . $file )) {
|
| 29 |
if (is_readable($folder . '/' . $file)) {
|
| 30 |
+
$files.=",". $folder . '/' . $file;
|
| 31 |
$filezise=filesize($folder . '/' . $file);
|
| 32 |
$backwpup_allfilezise=$backwpup_allfilezise+$filezise;
|
| 33 |
BackWPupFunctions::joblog($logtime,__('File to Backup:','backwpup').' '.$folder . '/' . $file.' '.BackWPupFunctions::formatBytes($filezise));
|
| 40 |
}
|
| 41 |
}
|
| 42 |
@closedir( $dir );
|
| 43 |
+
return str_replace(',,',',',$files);;
|
| 44 |
}
|
| 45 |
|
| 46 |
|
| 47 |
//Make filelist
|
| 48 |
+
$backwupu_exclude=array(); $dirinclude=array(); $allfilezise=''; $filelist='';
|
| 49 |
|
| 50 |
if (!empty($jobs[$jobid]['fileexclude']))
|
| 51 |
$backwupu_exclude=split(',',$jobs[$jobid]['fileexclude']);
|
| 72 |
if (is_array($dirinclude)) {
|
| 73 |
foreach($dirinclude as $dirincludevalue) {
|
| 74 |
if (is_dir($dirincludevalue))
|
| 75 |
+
$filelist .=",".backwpup_list_files(untrailingslashit(str_replace('\\','/',$dirincludevalue)));
|
| 76 |
}
|
| 77 |
}
|
|
|
|
| 78 |
|
| 79 |
+
if (empty($filelist)) {
|
| 80 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('No files to Backup','backwpup'));
|
| 81 |
unset($filelist); //clean vars
|
| 82 |
} else {
|
| 83 |
BackWPupFunctions::joblog($logtime,__('Size off all files:','backwpup').' '.BackWPupFunctions::formatBytes($backwpup_allfilezise));
|
| 84 |
}
|
| 85 |
|
|
|
|
|
|
|
| 86 |
//Create Zip File
|
| 87 |
+
if (!empty($filelist)) {
|
| 88 |
+
BackWPupFunctions::needfreememory(8388608); //8MB free memory for zip
|
| 89 |
BackWPupFunctions::joblog($logtime,__('Create Backup Zip file...','backwpup'));
|
| 90 |
$zipbackupfile = new PclZip($backupfile);
|
| 91 |
if (0==$zipbackupfile -> create($filelist,PCLZIP_OPT_REMOVE_PATH,str_replace('\\','/',ABSPATH),PCLZIP_OPT_ADD_TEMP_FILE_ON)) {
|
| 92 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Zip file create:','backwpup').' '.$zipbackupfile->errorInfo(true));
|
| 93 |
}
|
| 94 |
+
unset($filelist);
|
| 95 |
if ($jobs[$jobid]['type']=='DB+FILE') {
|
| 96 |
BackWPupFunctions::joblog($logtime,__('Database file size:','backwpup').' '.BackWPupFunctions::formatBytes(filesize(BackWPupFunctions::get_temp_dir().'backwpup/'.DB_NAME.'.sql')));
|
| 97 |
BackWPupFunctions::joblog($logtime,__('Add Database dump to Backup Zip file...','backwpup'));
|
| 99 |
BackWPupFunctions::joblog($logtime,__('ERROR:','backwpup').' '.__('Zip file create Add Database dump:','backwpup').' '.$zipbackupfile->errorInfo(true));
|
| 100 |
}
|
| 101 |
}
|
|
|
|
| 102 |
unset($zipbackupfile);
|
|
|
|
| 103 |
BackWPupFunctions::joblog($logtime,__('Backup Zip file create done!','backwpup'));
|
| 104 |
}
|
| 105 |
|
app/functions.php
CHANGED
|
@@ -306,14 +306,13 @@ class BackWPupFunctions {
|
|
| 306 |
//Make Log File for Jobs.
|
| 307 |
function joblog($logtime,$entry) {
|
| 308 |
global $wpdb;
|
| 309 |
-
$
|
| 310 |
if (substr($entry,0,strlen(__('ERROR:','backwpup')))==__('ERROR:','backwpup'))
|
| 311 |
-
$
|
| 312 |
if (substr($entry,0,strlen(__('WARNING:','backwpup')))==__('WARNING:','backwpup'))
|
| 313 |
-
$
|
| 314 |
-
|
| 315 |
-
echo date('Y-m-d H:i
|
| 316 |
-
$wpdb->flush();
|
| 317 |
flush();
|
| 318 |
ob_flush();
|
| 319 |
}
|
|
@@ -410,6 +409,31 @@ class BackWPupFunctions {
|
|
| 410 |
wp_add_dashboard_widget( 'backwpup_dashboard_widget', 'BackWPup', array ('BackWPupFunctions', 'dashboard_output') );
|
| 411 |
}
|
| 412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
// add all action and so on only if plugin loaded.
|
| 414 |
function init() {
|
| 415 |
//add Menu
|
|
@@ -422,7 +446,7 @@ class BackWPupFunctions {
|
|
| 422 |
//Actions for Cron job
|
| 423 |
add_action('backwpup_cron', array('BackWPupFunctions', 'dojob'));
|
| 424 |
//add Dashboard widget
|
| 425 |
-
add_action(
|
| 426 |
}
|
| 427 |
}
|
| 428 |
|
| 306 |
//Make Log File for Jobs.
|
| 307 |
function joblog($logtime,$entry) {
|
| 308 |
global $wpdb;
|
| 309 |
+
$errors=0;$warnings=0;
|
| 310 |
if (substr($entry,0,strlen(__('ERROR:','backwpup')))==__('ERROR:','backwpup'))
|
| 311 |
+
$errors=1;
|
| 312 |
if (substr($entry,0,strlen(__('WARNING:','backwpup')))==__('WARNING:','backwpup'))
|
| 313 |
+
$warnings=1;
|
| 314 |
+
mysql_query("UPDATE ".$wpdb->backwpup_logs." SET error=error+".$errors.", warning=warning+".$warnings.", log=concat(log,'".mysql_real_escape_string(date('Y-m-d H:i:s').": ".$entry."\n")."') WHERE logtime=".$logtime);
|
| 315 |
+
echo date('Y-m-d H:i:s').": ".$entry."\n";
|
|
|
|
| 316 |
flush();
|
| 317 |
ob_flush();
|
| 318 |
}
|
| 409 |
wp_add_dashboard_widget( 'backwpup_dashboard_widget', 'BackWPup', array ('BackWPupFunctions', 'dashboard_output') );
|
| 410 |
}
|
| 411 |
|
| 412 |
+
//Sed mail send Method
|
| 413 |
+
function use_mail_method() {
|
| 414 |
+
global $phpmailer;
|
| 415 |
+
$cfg=get_option('backwpup'); //Load Settings
|
| 416 |
+
if ($cfg['mailmethod']=="SMTP") {
|
| 417 |
+
$smtpport=25;
|
| 418 |
+
$smtphost=$cfg['mailhost'];
|
| 419 |
+
if (false !== strpos($cfg['mailhost'],':')) //look for port
|
| 420 |
+
list($smtphost,$smtpport)=split(':',$cfg['mailhost'],2);
|
| 421 |
+
$phpmailer->Host=$smtphost;
|
| 422 |
+
$phpmailer->Port=$smtpport;
|
| 423 |
+
$phpmailer->SMTPSecure=$cfg['mailsecure'];
|
| 424 |
+
$phpmailer->Username=$cfg['mailuser'];
|
| 425 |
+
$phpmailer->Password=$cfg['mailpass'];
|
| 426 |
+
if (!empty($cfg['mailuser']) and !empty($cfg['mailpass']))
|
| 427 |
+
$phpmailer->SMTPAuth=true;
|
| 428 |
+
$phpmailer->IsSMTP();
|
| 429 |
+
} elseif ($cfg['mailmethod']=="Sendmail") {
|
| 430 |
+
$phpmailer->Sendmail=$cfg['mailsendmail'];
|
| 431 |
+
$phpmailer->IsSendmail();
|
| 432 |
+
} else {
|
| 433 |
+
$phpmailer->IsMail();
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
// add all action and so on only if plugin loaded.
|
| 438 |
function init() {
|
| 439 |
//add Menu
|
| 446 |
//Actions for Cron job
|
| 447 |
add_action('backwpup_cron', array('BackWPupFunctions', 'dojob'));
|
| 448 |
//add Dashboard widget
|
| 449 |
+
add_action('wp_dashboard_setup', array('BackWPupFunctions', 'add_dashboard'));
|
| 450 |
}
|
| 451 |
}
|
| 452 |
|
app/options-edit.php
CHANGED
|
@@ -172,8 +172,8 @@ _e('Oldest files will deletet first.','backwpup');
|
|
| 172 |
<th scope="row"><label for="mailaddress"><?PHP _e('Place Backup to FTP Server:','backwpup'); ?></label></th>
|
| 173 |
<td>
|
| 174 |
<span class="description"><?PHP _e('Ftp Hostname:','backwpup'); ?></span><input name="ftphost" type="text" value="<?PHP echo $jobs[$jobid]['ftphost'];?>" class="regular-text" /><br />
|
| 175 |
-
<span class="description"><?PHP _e('Ftp Username:','backwpup'); ?></span><input name="ftpuser" type="text" value="<?PHP echo $jobs[$jobid]['ftpuser'];?>" class="user"
|
| 176 |
-
<span class="description"><?PHP _e('Ftp Password:','backwpup'); ?></span><input name="ftppass" type="password" value="<?PHP echo $jobs[$jobid]['ftppass'];?>" class="password"
|
| 177 |
<span class="description"><?PHP _e('Ftp directory:','backwpup'); ?></span><input name="ftpdir" type="text" value="<?PHP echo $jobs[$jobid]['ftpdir'];?>" class="regular-text" /><br />
|
| 178 |
<span class="description"><?PHP _e('Max Backup fieles on ftp:','backwpup'); ?></span>
|
| 179 |
<?PHP
|
| 172 |
<th scope="row"><label for="mailaddress"><?PHP _e('Place Backup to FTP Server:','backwpup'); ?></label></th>
|
| 173 |
<td>
|
| 174 |
<span class="description"><?PHP _e('Ftp Hostname:','backwpup'); ?></span><input name="ftphost" type="text" value="<?PHP echo $jobs[$jobid]['ftphost'];?>" class="regular-text" /><br />
|
| 175 |
+
<span class="description"><?PHP _e('Ftp Username:','backwpup'); ?></span><input name="ftpuser" type="text" value="<?PHP echo $jobs[$jobid]['ftpuser'];?>" class="user" /><br />
|
| 176 |
+
<span class="description"><?PHP _e('Ftp Password:','backwpup'); ?></span><input name="ftppass" type="password" value="<?PHP echo $jobs[$jobid]['ftppass'];?>" class="password" /><br />
|
| 177 |
<span class="description"><?PHP _e('Ftp directory:','backwpup'); ?></span><input name="ftpdir" type="text" value="<?PHP echo $jobs[$jobid]['ftpdir'];?>" class="regular-text" /><br />
|
| 178 |
<span class="description"><?PHP _e('Max Backup fieles on ftp:','backwpup'); ?></span>
|
| 179 |
<?PHP
|
app/options-save.php
CHANGED
|
@@ -36,7 +36,12 @@ class BackWPupOptions {
|
|
| 36 |
|
| 37 |
function config() {
|
| 38 |
$cfg=get_option('backwpup'); //Load Settings
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
update_option('backwpup',$cfg); //Save Settings
|
| 41 |
}
|
| 42 |
|
| 36 |
|
| 37 |
function config() {
|
| 38 |
$cfg=get_option('backwpup'); //Load Settings
|
| 39 |
+
$cfg['mailmethod']=$_POST['mailmethod'];
|
| 40 |
+
$cfg['mailsendmail']=str_replace('\\','/',stripslashes($_POST['mailsendmail']));
|
| 41 |
+
$cfg['mailsecure']=$_POST['mailsecure'];
|
| 42 |
+
$cfg['mailhost']=$_POST['mailhost'];
|
| 43 |
+
$cfg['mailuser']=$_POST['mailuser'];
|
| 44 |
+
$cfg['mailpass']=$_POST['mailpass'];
|
| 45 |
update_option('backwpup',$cfg); //Save Settings
|
| 46 |
}
|
| 47 |
|
app/options-settings.php
CHANGED
|
@@ -23,6 +23,37 @@
|
|
| 23 |
</td>
|
| 24 |
</tr>
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
</table>
|
| 27 |
|
| 28 |
<p class="submit">
|
| 23 |
</td>
|
| 24 |
</tr>
|
| 25 |
|
| 26 |
+
<tr valign="top">
|
| 27 |
+
<th scope="row"><label for="mailaddress"><?PHP _e('Mail Send:','backwpup'); ?></label></th>
|
| 28 |
+
<td>
|
| 29 |
+
<span class="description"><?PHP _e('Send mail method:','backwpup'); ?></span>
|
| 30 |
+
<?PHP
|
| 31 |
+
echo '<select name="mailmethod">';
|
| 32 |
+
echo '<option value="mail"'.selected('mail',$cfg['mailmethod'],false).'>'.__('PHP: mail()','backwpup').'</option>';
|
| 33 |
+
echo '<option value="Sendmail"'.selected('Sendmail',$cfg['mailmethod'],false).'>'.__('Sendmail','backwpup').'</option>';
|
| 34 |
+
echo '<option value="SMTP"'.selected('SMTP',$cfg['mailmethod'],false).'>'.__('SMTP','backwpup').'</option>';
|
| 35 |
+
echo '</select>';
|
| 36 |
+
if (empty($cfg['mailsendmail'])) {
|
| 37 |
+
$cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
| 38 |
+
}
|
| 39 |
+
?><br />
|
| 40 |
+
<span class="description"><?PHP _e('Sendmail Path:','backwpup'); ?></span><input name="mailhost" type="text" value="<?PHP echo $cfg['mailsendmail'];?>" class="regular-text" /><br />
|
| 41 |
+
<span class="description"><?PHP _e('SMTP Hostname:','backwpup'); ?></span><input name="mailhost" type="text" value="<?PHP echo $cfg['mailhost'];?>" class="regular-text" /><br />
|
| 42 |
+
<span class="description"><?PHP _e('SMTP Secure Connection:','backwpup'); ?></span><?PHP
|
| 43 |
+
echo '<select name="mailsecure">';
|
| 44 |
+
echo '<option value=""'.selected('',$cfg['mailsecure'],false).'>'.__('none','backwpup').'</option>';
|
| 45 |
+
echo '<option value="ssl"'.selected('ssl',$cfg['mailsecure'],false).'>SSL</option>';
|
| 46 |
+
echo '<option value="tls"'.selected('tls',$cfg['mailsecure'],false).'>TLS</option>';
|
| 47 |
+
echo '</select>';
|
| 48 |
+
if (!empty($cfg['mailsendmail']))
|
| 49 |
+
$cfg['mailsendmail']='/usr/sbin/sendmail';
|
| 50 |
+
?><br />
|
| 51 |
+
<span class="description"><?PHP _e('SMTP Username:','backwpup'); ?></span><input name="mailuser" type="text" value="<?PHP echo $cfg['mailuser'];?>" class="user" /><br />
|
| 52 |
+
<span class="description"><?PHP _e('SMTP Password:','backwpup'); ?></span><input name="mailpass" type="password" value="<?PHP echo $cfg['mailpass'];?>" class="password" /><br />
|
| 53 |
+
</td>
|
| 54 |
+
</tr>
|
| 55 |
+
|
| 56 |
+
|
| 57 |
</table>
|
| 58 |
|
| 59 |
<p class="submit">
|
backwpup.php
CHANGED
|
@@ -4,7 +4,7 @@ Plugin Name: BackWPup
|
|
| 4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
| 5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
| 6 |
Author: Daniel Hüsken
|
| 7 |
-
Version: 0.6.
|
| 8 |
Author URI: http://danielhuesken.de
|
| 9 |
Text Domain: backwpup
|
| 10 |
Domain Path: /lang/
|
|
@@ -32,7 +32,7 @@ Domain Path: /lang/
|
|
| 32 |
//Set plugin dirname
|
| 33 |
define('BACKWPUP_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
|
| 34 |
//Set Plugin Version
|
| 35 |
-
define('BACKWPUP_VERSION', '0.6.
|
| 36 |
//BackWPup Log Table Name
|
| 37 |
global $wpdb;
|
| 38 |
$wpdb->backwpup_logs = $wpdb->prefix.'backwpup_logs';
|
| 4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
| 5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
| 6 |
Author: Daniel Hüsken
|
| 7 |
+
Version: 0.6.1
|
| 8 |
Author URI: http://danielhuesken.de
|
| 9 |
Text Domain: backwpup
|
| 10 |
Domain Path: /lang/
|
| 32 |
//Set plugin dirname
|
| 33 |
define('BACKWPUP_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
|
| 34 |
//Set Plugin Version
|
| 35 |
+
define('BACKWPUP_VERSION', '0.6.1');
|
| 36 |
//BackWPup Log Table Name
|
| 37 |
global $wpdb;
|
| 38 |
$wpdb->backwpup_logs = $wpdb->prefix.'backwpup_logs';
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
=== BackWPup ===
|
| 2 |
Contributors: danielhuesken
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0¤cy_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8
|
| 4 |
-
Tags: backup, admin, file, Database, mysql,
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 2.8.1
|
| 7 |
-
Stable tag: 0.6.
|
| 8 |
|
| 9 |
Backup and more of your WordPress Blog Database and Files
|
| 10 |
|
|
@@ -48,7 +48,12 @@ You must import the Database Dump with Charaktercoding:latin1
|
|
| 48 |
1. Job Page
|
| 49 |
|
| 50 |
== Changelog ==
|
| 51 |
-
= 0.6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
* Add Dashboard Widget
|
| 53 |
* Add Database Check
|
| 54 |
* Add Backup file transfer to FTP Server
|
| 1 |
=== BackWPup ===
|
| 2 |
Contributors: danielhuesken
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0¤cy_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8
|
| 4 |
+
Tags: backup, admin, file, Database, mysql, cron
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 2.8.1
|
| 7 |
+
Stable tag: 0.6.1
|
| 8 |
|
| 9 |
Backup and more of your WordPress Blog Database and Files
|
| 10 |
|
| 48 |
1. Job Page
|
| 49 |
|
| 50 |
== Changelog ==
|
| 51 |
+
= 0.6.1 =
|
| 52 |
+
* Added setting for Send Mail type.
|
| 53 |
+
* Optimize Memory usage again
|
| 54 |
+
* Fixed Bug that cron not work
|
| 55 |
+
|
| 56 |
+
= 0.6.0 =
|
| 57 |
* Add Dashboard Widget
|
| 58 |
* Add Database Check
|
| 59 |
* Add Backup file transfer to FTP Server
|
