Version Description
- Fix to backup folder create & checks
- Security Enhancements
- Add logging to filesystem create folder
Download this release
Release Info
Developer | cssimmon |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.7.4 |
Comparing to | |
See all releases |
Code changes from version 1.7.3 to 1.7.4
- js/admin.js +1 -1
- lib/includes/backup.php +40 -30
- lib/includes/class-filesystem.php +8 -3
- lib/includes/listlogs.php +3 -3
- readme.txt +5 -1
- views/backup.php +1 -1
- wp-backitup.php +2 -2
js/admin.js
CHANGED
@@ -147,7 +147,7 @@
|
|
147 |
console.log("JSON error response received.");
|
148 |
status_message='An unexpected error has occurred: ' + jsonData.message;
|
149 |
|
150 |
-
|
151 |
|
152 |
var unexpected_error= $('.backup-unexpected-error');
|
153 |
unexpected_error.html(status_message);
|
147 |
console.log("JSON error response received.");
|
148 |
status_message='An unexpected error has occurred: ' + jsonData.message;
|
149 |
|
150 |
+
//$('.backup-status').hide();
|
151 |
|
152 |
var unexpected_error= $('.backup-unexpected-error');
|
153 |
unexpected_error.html(status_message);
|
lib/includes/backup.php
CHANGED
@@ -110,42 +110,51 @@ sleep(3);//For UI only
|
|
110 |
//die();
|
111 |
//TEST END HERE
|
112 |
|
113 |
-
$logger->log('CLEANUP');
|
|
|
114 |
cleanup_BackupFolder($wp_backup->backup_folder_root);
|
115 |
-
|
|
|
|
|
116 |
check_BackupFolder($wp_backup->backup_project_path);
|
|
|
117 |
set_status('preparing',$complete,false);
|
|
|
118 |
|
119 |
//Backup the database
|
120 |
-
$logger->log('SQL EXPORT');
|
121 |
set_status('backupdb',$active,true);
|
122 |
sleep(3);//For UI only
|
123 |
$sqlFileName=$wp_backup->backup_project_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
124 |
export_Database($sqlFileName);
|
125 |
set_status('backupdb',$complete,false);
|
|
|
126 |
|
127 |
//Extract the site info
|
128 |
-
$logger->log('SITE INFO');
|
129 |
set_status('infofile',$active,true);
|
130 |
sleep(3);//For UI only
|
131 |
create_SiteInfoFile($wp_backup->backup_project_path);
|
132 |
set_status('infofile',$complete,false);
|
|
|
133 |
|
134 |
//Backup the WP-Content
|
135 |
-
$logger->log('WP CONTENT');
|
136 |
set_status('backupfiles',$active,true);
|
137 |
sleep(3);//For UI only
|
138 |
backup_wpcontent();
|
139 |
set_status('backupfiles',$complete,false);
|
|
|
140 |
|
141 |
//Zip up the backup folder
|
142 |
-
$logger->log('ZIP');
|
143 |
set_status('zipfile',$active,true);
|
144 |
sleep(3);//For UI only
|
145 |
$logger->log('Zip Up the Backup Folder:'.$wp_backup->backup_project_path);
|
146 |
$zip = new WPBackItUp_Zip($logger);
|
147 |
$zip->compress($wp_backup->backup_project_path, $wp_backup->backup_folder_root);
|
148 |
set_status('zipfile',$complete,false);
|
|
|
149 |
|
150 |
//Send JSON response
|
151 |
$jsonResponse = new stdClass();
|
@@ -161,10 +170,11 @@ if (file_exists($logger->logFilePath)) {
|
|
161 |
}
|
162 |
|
163 |
//Cleanup
|
164 |
-
$logger->log('CLEANUP');
|
165 |
set_status('cleanup',$active,true);
|
166 |
cleanup($wp_backup->backup_project_path);
|
167 |
set_status('cleanup',$complete,false);
|
|
|
168 |
|
169 |
//Send success Email to user before cleanup
|
170 |
send_backup_notification_email(null,true);
|
@@ -283,7 +293,7 @@ function check_BackupFolder($path){
|
|
283 |
}
|
284 |
}
|
285 |
|
286 |
-
function
|
287 |
global $logger;
|
288 |
$fileSystem = new WPBackItUp_FileSystem($logger);
|
289 |
|
@@ -390,28 +400,28 @@ function cleanup_on_failure($path){
|
|
390 |
}
|
391 |
|
392 |
function cleanup_BackupFolder($dir){
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
}
|
416 |
|
417 |
|
110 |
//die();
|
111 |
//TEST END HERE
|
112 |
|
113 |
+
$logger->log('**CLEANUP**');
|
114 |
+
|
115 |
cleanup_BackupFolder($wp_backup->backup_folder_root);
|
116 |
+
create_folder($wp_backup->backup_folder_root); //Create Root Folder
|
117 |
+
|
118 |
+
create_folder($wp_backup->backup_project_path);//Create Project Folder
|
119 |
check_BackupFolder($wp_backup->backup_project_path);
|
120 |
+
|
121 |
set_status('preparing',$complete,false);
|
122 |
+
$logger->log('**END CLEANUP**');
|
123 |
|
124 |
//Backup the database
|
125 |
+
$logger->log('**SQL EXPORT**');
|
126 |
set_status('backupdb',$active,true);
|
127 |
sleep(3);//For UI only
|
128 |
$sqlFileName=$wp_backup->backup_project_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
129 |
export_Database($sqlFileName);
|
130 |
set_status('backupdb',$complete,false);
|
131 |
+
$logger->log('**END SQL EXPORT**');
|
132 |
|
133 |
//Extract the site info
|
134 |
+
$logger->log('**SITE INFO**');
|
135 |
set_status('infofile',$active,true);
|
136 |
sleep(3);//For UI only
|
137 |
create_SiteInfoFile($wp_backup->backup_project_path);
|
138 |
set_status('infofile',$complete,false);
|
139 |
+
$logger->log('**END SITE INFO**');
|
140 |
|
141 |
//Backup the WP-Content
|
142 |
+
$logger->log('**WP CONTENT**');
|
143 |
set_status('backupfiles',$active,true);
|
144 |
sleep(3);//For UI only
|
145 |
backup_wpcontent();
|
146 |
set_status('backupfiles',$complete,false);
|
147 |
+
$logger->log('**END WP CONTENT**');
|
148 |
|
149 |
//Zip up the backup folder
|
150 |
+
$logger->log('**BACKUP ZIP**');
|
151 |
set_status('zipfile',$active,true);
|
152 |
sleep(3);//For UI only
|
153 |
$logger->log('Zip Up the Backup Folder:'.$wp_backup->backup_project_path);
|
154 |
$zip = new WPBackItUp_Zip($logger);
|
155 |
$zip->compress($wp_backup->backup_project_path, $wp_backup->backup_folder_root);
|
156 |
set_status('zipfile',$complete,false);
|
157 |
+
$logger->log('**END BACKUP ZIP**');
|
158 |
|
159 |
//Send JSON response
|
160 |
$jsonResponse = new stdClass();
|
170 |
}
|
171 |
|
172 |
//Cleanup
|
173 |
+
$logger->log('**CLEANUP**');
|
174 |
set_status('cleanup',$active,true);
|
175 |
cleanup($wp_backup->backup_project_path);
|
176 |
set_status('cleanup',$complete,false);
|
177 |
+
$logger->log('**END CLEANUP**');
|
178 |
|
179 |
//Send success Email to user before cleanup
|
180 |
send_backup_notification_email(null,true);
|
293 |
}
|
294 |
}
|
295 |
|
296 |
+
function create_folder($path){
|
297 |
global $logger;
|
298 |
$fileSystem = new WPBackItUp_FileSystem($logger);
|
299 |
|
400 |
}
|
401 |
|
402 |
function cleanup_BackupFolder($dir){
|
403 |
+
global $logger;
|
404 |
+
$logger->log('Cleanup Backup Folder:'.$dir);
|
405 |
+
$ignore = array('cgi-bin','.','..','._');
|
406 |
+
if( is_dir($dir) ){
|
407 |
+
if($dh = opendir($dir)) {
|
408 |
+
while( ($file = readdir($dh)) !== false ) {
|
409 |
+
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
410 |
+
if (!in_array($file, $ignore) && substr($file, 0, 1) != '.' && $ext!="zip" && $ext!="log") { //Check the file is not in the ignore array
|
411 |
+
if(!is_dir($dir .'/'. $file)) {
|
412 |
+
unlink($dir .'/'. $file);
|
413 |
+
} else {
|
414 |
+
$fileSystem = new WPBackItUp_FileSystem($logger);
|
415 |
+
$fileSystem->recursive_delete($dir.'/'. $file, $ignore);
|
416 |
+
}
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
@rmdir($dir);
|
421 |
+
closedir($dh);
|
422 |
+
}
|
423 |
+
$logger->log('Cleanup Backup Folder completed:'.$dir);
|
424 |
+
return true;
|
425 |
}
|
426 |
|
427 |
|
lib/includes/class-filesystem.php
CHANGED
@@ -91,14 +91,19 @@ class WPBackItUp_FileSystem {
|
|
91 |
fclose($fsrc);
|
92 |
fclose($fdest);
|
93 |
} catch(Exception $e) {
|
94 |
-
$this->logger->log('(FileSystem.recursive_copy) Exception: ' .$e);
|
95 |
return false;
|
96 |
}
|
97 |
} else { //If $file is a directory
|
98 |
$destdir = $target_path .$file; //Modify the destination dir
|
99 |
if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
|
100 |
$this->logger->log('(FileSytem.recursive_copy) Create Folder: ' .$destdir);
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
$this->recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
|
104 |
}
|
@@ -185,7 +190,7 @@ class WPBackItUp_FileSystem {
|
|
185 |
($file == "cgi-bin" )) {
|
186 |
$ignore = true;
|
187 |
|
188 |
-
$this->logger->log('(FileSystem.
|
189 |
}
|
190 |
|
191 |
return $ignore;
|
91 |
fclose($fsrc);
|
92 |
fclose($fdest);
|
93 |
} catch(Exception $e) {
|
94 |
+
$this->logger->log('(FileSystem.recursive_copy) File Copy Exception: ' .$e);
|
95 |
return false;
|
96 |
}
|
97 |
} else { //If $file is a directory
|
98 |
$destdir = $target_path .$file; //Modify the destination dir
|
99 |
if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
|
100 |
$this->logger->log('(FileSytem.recursive_copy) Create Folder: ' .$destdir);
|
101 |
+
try {
|
102 |
+
@mkdir($destdir, 0755);
|
103 |
+
} catch(Exception $e) {
|
104 |
+
$this->logger->log('(FileSystem.recursive_copy)Create Folder Exception: ' .$e);
|
105 |
+
return false;
|
106 |
+
}
|
107 |
}
|
108 |
$this->recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
|
109 |
}
|
190 |
($file == "cgi-bin" )) {
|
191 |
$ignore = true;
|
192 |
|
193 |
+
$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
|
194 |
}
|
195 |
|
196 |
return $ignore;
|
lib/includes/listlogs.php
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
|
23 |
}
|
24 |
} else {
|
25 |
-
echo('No logs in backup folder');
|
26 |
}
|
27 |
|
28 |
//Get logs in logs folder
|
@@ -36,7 +36,7 @@
|
|
36 |
|
37 |
}
|
38 |
} else {
|
39 |
-
echo('No logs in logs folder');
|
40 |
}
|
41 |
die();
|
42 |
}
|
@@ -54,7 +54,7 @@
|
|
54 |
if(file_exists($log_path) ) {
|
55 |
stream_file($log_path, $log_filename);
|
56 |
} else {
|
57 |
-
echo('No file found in folder');
|
58 |
}
|
59 |
}
|
60 |
die();
|
22 |
|
23 |
}
|
24 |
} else {
|
25 |
+
echo('No logs in backup folder<br>');
|
26 |
}
|
27 |
|
28 |
//Get logs in logs folder
|
36 |
|
37 |
}
|
38 |
} else {
|
39 |
+
echo('No logs in logs folder<br>');
|
40 |
}
|
41 |
die();
|
42 |
}
|
54 |
if(file_exists($log_path) ) {
|
55 |
stream_file($log_path, $log_filename);
|
56 |
} else {
|
57 |
+
echo('No log file found in folder<br>');
|
58 |
}
|
59 |
}
|
60 |
die();
|
readme.txt
CHANGED
@@ -91,10 +91,14 @@ Yes.
|
|
91 |
3. When the backup has been created, click the download link to access a zipped backup of your site.
|
92 |
|
93 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
94 |
= 1.7.3 =
|
95 |
* Fix 1.7.2 deployment issue
|
96 |
|
97 |
-
|
98 |
= 1.7.2 =
|
99 |
* User Interface improvements
|
100 |
* Add backup and restore folder check
|
91 |
3. When the backup has been created, click the download link to access a zipped backup of your site.
|
92 |
|
93 |
== Changelog ==
|
94 |
+
= 1.7.4 =
|
95 |
+
* Fix to backup folder create & checks
|
96 |
+
* Security Enhancements
|
97 |
+
* Add logging to filesystem create folder
|
98 |
+
|
99 |
= 1.7.3 =
|
100 |
* Fix 1.7.2 deployment issue
|
101 |
|
|
|
102 |
= 1.7.2 =
|
103 |
* User Interface improvements
|
104 |
* Add backup and restore folder check
|
views/backup.php
CHANGED
@@ -33,7 +33,7 @@
|
|
33 |
$backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
|
34 |
$backup_folder_exists=false;
|
35 |
if( !is_dir($backup_dir) ) {
|
36 |
-
if (
|
37 |
$backup_folder_exists=true;
|
38 |
}
|
39 |
}else{
|
33 |
$backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
|
34 |
$backup_folder_exists=false;
|
35 |
if( !is_dir($backup_dir) ) {
|
36 |
+
if (@mkdir($backup_dir, 0755)){
|
37 |
$backup_folder_exists=true;
|
38 |
}
|
39 |
}else{
|
wp-backitup.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
Plugin Name: WP Backitup
|
13 |
Plugin URI: http://www.wpbackitup.com
|
14 |
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
-
Version: 1.7.
|
16 |
Author: Chris Simmons
|
17 |
Author URI: http://www.wpbackitup.com
|
18 |
License: GPL3
|
@@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34 |
*/
|
35 |
|
36 |
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
-
define( 'WPBACKITUP__VERSION', '1.7.
|
38 |
define( 'WPBACKITUP__DEBUG', false );
|
39 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|
12 |
Plugin Name: WP Backitup
|
13 |
Plugin URI: http://www.wpbackitup.com
|
14 |
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
+
Version: 1.7.4
|
16 |
Author: Chris Simmons
|
17 |
Author URI: http://www.wpbackitup.com
|
18 |
License: GPL3
|
34 |
*/
|
35 |
|
36 |
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
+
define( 'WPBACKITUP__VERSION', '1.7.4');
|
38 |
define( 'WPBACKITUP__DEBUG', false );
|
39 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|