Version Description
Download this release
Release Info
Developer | willmot |
Plugin | BackUpWordPress |
Version | 1.6.4 |
Comparing to | |
See all releases |
Code changes from version 1.6.3 to 1.6.4
- admin.actions.php +2 -1
- admin.menus.php +1 -1
- assets/hmbkp.js +2 -0
- functions/backup.functions.php +1 -1
- functions/core.functions.php +11 -2
- functions/interface.functions.php +7 -33
- functions/wp-cli.php +2 -2
- hm-backup/hm-backup.php +59 -42
- plugin.php +1 -1
- readme.txt +13 -1
admin.actions.php
CHANGED
@@ -157,7 +157,8 @@ function hmbkp_request_download_backup() {
|
|
157 |
|
158 |
if ( empty( $_GET['hmbkp_download'] ) )
|
159 |
return;
|
160 |
-
|
|
|
161 |
if ( file_exists( hmbkp_path() . '/.htaccess' ) )
|
162 |
unlink( hmbkp_path() . '/.htaccess' );
|
163 |
|
157 |
|
158 |
if ( empty( $_GET['hmbkp_download'] ) )
|
159 |
return;
|
160 |
+
|
161 |
+
// Force the .htaccess to be rebuilt
|
162 |
if ( file_exists( hmbkp_path() . '/.htaccess' ) )
|
163 |
unlink( hmbkp_path() . '/.htaccess' );
|
164 |
|
admin.menus.php
CHANGED
@@ -53,7 +53,7 @@ function hmbkp_contextual_help() {
|
|
53 |
$warning = '';
|
54 |
|
55 |
// Check if help is for the right version.
|
56 |
-
if ( ! empty( $plugin->version ) && version_compare( HMBKP_VERSION, $plugin->version, '
|
57 |
$warning = sprintf( '<div id="message" class="updated inline"><p><strong>' . __( 'You are not using the latest stable version of BackUpWordPress', 'hmbkp' ) . '</strong>' . __( ' — The information below is for version %s. View the readme.txt file for help specific to version %s.', 'hmbkp' ) . '</p></div>', '<code>' . $plugin->version . '</code>', '<code>' . HMBKP_VERSION . '</code>' );
|
58 |
|
59 |
ob_start();
|
53 |
$warning = '';
|
54 |
|
55 |
// Check if help is for the right version.
|
56 |
+
if ( ! empty( $plugin->version ) && version_compare( HMBKP_VERSION, $plugin->version, '!=' ) )
|
57 |
$warning = sprintf( '<div id="message" class="updated inline"><p><strong>' . __( 'You are not using the latest stable version of BackUpWordPress', 'hmbkp' ) . '</strong>' . __( ' — The information below is for version %s. View the readme.txt file for help specific to version %s.', 'hmbkp' ) . '</p></div>', '<code>' . $plugin->version . '</code>', '<code>' . HMBKP_VERSION . '</code>' );
|
58 |
|
59 |
ob_start();
|
assets/hmbkp.js
CHANGED
@@ -24,6 +24,8 @@ jQuery( document ).ready( function( $ ) {
|
|
24 |
|
25 |
$( '#hmbkp_backup:not(.hmbkp_running)' ).live( 'click', function( e ) {
|
26 |
|
|
|
|
|
27 |
ajaxRequest = $.get( ajaxurl, { 'action' : 'hmbkp_backup' } );
|
28 |
|
29 |
$( this ).text( 'Starting Backup' ).addClass( 'hmbkp_running' );
|
24 |
|
25 |
$( '#hmbkp_backup:not(.hmbkp_running)' ).live( 'click', function( e ) {
|
26 |
|
27 |
+
$.ajaxSetup( { 'cache' : false } );
|
28 |
+
|
29 |
ajaxRequest = $.get( ajaxurl, { 'action' : 'hmbkp_backup' } );
|
30 |
|
31 |
$( this ).text( 'Starting Backup' ).addClass( 'hmbkp_running' );
|
functions/backup.functions.php
CHANGED
@@ -80,7 +80,7 @@ function hmbkp_get_backups() {
|
|
80 |
endif;
|
81 |
|
82 |
// If there is a custom backups directory and it's not writable then include those backups as well
|
83 |
-
if ( defined( 'HMBKP_PATH' ) && HMBKP_PATH && is_dir( HMBKP_PATH ) && !is_writable( HMBKP_PATH ) ) :
|
84 |
|
85 |
if ( $handle = opendir( HMBKP_PATH ) ) :
|
86 |
|
80 |
endif;
|
81 |
|
82 |
// If there is a custom backups directory and it's not writable then include those backups as well
|
83 |
+
if ( defined( 'HMBKP_PATH' ) && HMBKP_PATH && is_dir( HMBKP_PATH ) && ! is_writable( HMBKP_PATH ) ) :
|
84 |
|
85 |
if ( $handle = opendir( HMBKP_PATH ) ) :
|
86 |
|
functions/core.functions.php
CHANGED
@@ -52,9 +52,16 @@ function hmbkp_deactivate() {
|
|
52 |
function hmbkp_update() {
|
53 |
|
54 |
// Every update
|
55 |
-
if ( version_compare( HMBKP_VERSION, get_option( 'hmbkp_plugin_version' ), '>' ) )
|
|
|
56 |
hmbkp_deactivate();
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
// Update from backUpWordPress 0.4.5
|
59 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
60 |
|
@@ -331,9 +338,11 @@ function hmbkp_path() {
|
|
331 |
|
332 |
$contents[] = '# ' . __( 'This .htaccess file ensures that other people cannot download your backup files.', 'hmbkp' );
|
333 |
$contents[] = '';
|
|
|
334 |
$contents[] = 'RewriteEngine On';
|
335 |
$contents[] = 'RewriteCond %{QUERY_STRING} !key=' . md5( HMBKP_SECURE_KEY );
|
336 |
$contents[] = 'RewriteRule (.*) - [F]';
|
|
|
337 |
$contents[] = '';
|
338 |
|
339 |
if ( ! file_exists( $htaccess ) && is_writable( $path ) && require_once( ABSPATH . '/wp-admin/includes/misc.php' ) )
|
@@ -506,7 +515,7 @@ function hmbkp_cleanup() {
|
|
506 |
if ( $handle = opendir( $hmbkp_path ) ) :
|
507 |
|
508 |
while ( false !== ( $file = readdir( $handle ) ) )
|
509 |
-
if ( $file
|
510 |
hmbkp_rmdirtree( trailingslashit( $hmbkp_path ) . $file );
|
511 |
|
512 |
closedir( $handle );
|
52 |
function hmbkp_update() {
|
53 |
|
54 |
// Every update
|
55 |
+
if ( version_compare( HMBKP_VERSION, get_option( 'hmbkp_plugin_version' ), '>' ) ) {
|
56 |
+
|
57 |
hmbkp_deactivate();
|
58 |
|
59 |
+
// Force .htaccess to be re-written
|
60 |
+
if ( file_exists( hmbkp_path() . '/.htaccess' ) )
|
61 |
+
unlink( hmbkp_path() . '/.htaccess' );
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
// Update from backUpWordPress 0.4.5
|
66 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
67 |
|
338 |
|
339 |
$contents[] = '# ' . __( 'This .htaccess file ensures that other people cannot download your backup files.', 'hmbkp' );
|
340 |
$contents[] = '';
|
341 |
+
$contents[] = '<IfModule mod_rewrite.c>';
|
342 |
$contents[] = 'RewriteEngine On';
|
343 |
$contents[] = 'RewriteCond %{QUERY_STRING} !key=' . md5( HMBKP_SECURE_KEY );
|
344 |
$contents[] = 'RewriteRule (.*) - [F]';
|
345 |
+
$contents[] = '</IfModule>';
|
346 |
$contents[] = '';
|
347 |
|
348 |
if ( ! file_exists( $htaccess ) && is_writable( $path ) && require_once( ABSPATH . '/wp-admin/includes/misc.php' ) )
|
515 |
if ( $handle = opendir( $hmbkp_path ) ) :
|
516 |
|
517 |
while ( false !== ( $file = readdir( $handle ) ) )
|
518 |
+
if ( ! in_array( $file, array( '.', '..', '.htaccess' ) ) && pathinfo( $file, PATHINFO_EXTENSION ) !== 'zip' )
|
519 |
hmbkp_rmdirtree( trailingslashit( $hmbkp_path ) . $file );
|
520 |
|
521 |
closedir( $handle );
|
functions/interface.functions.php
CHANGED
@@ -161,17 +161,6 @@ function hmbkp_admin_notices() {
|
|
161 |
add_action( 'admin_notices', 'hmbkp_backup_errors_notice' );
|
162 |
|
163 |
endif;
|
164 |
-
|
165 |
-
// If there are any warnings reported in the backup
|
166 |
-
if ( hmbkp_backup_warnings_message() ) :
|
167 |
-
|
168 |
-
function hmbkp_backup_warnings_notice() {
|
169 |
-
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress detected issues with your last backup.', 'hmbkp' ) . '</strong><a href="' . add_query_arg( 'action', 'hmbkp_dismiss_error' ) . '" style="float: right;" class="button">Dismiss</a></p>' . hmbkp_backup_warnings_message() . '</div>';
|
170 |
-
}
|
171 |
-
add_action( 'admin_notices', 'hmbkp_backup_warnings_notice' );
|
172 |
-
|
173 |
-
endif;
|
174 |
-
|
175 |
|
176 |
}
|
177 |
add_action( 'admin_head', 'hmbkp_admin_notices' );
|
@@ -192,6 +181,13 @@ function hmbkp_plugin_row( $plugins ) {
|
|
192 |
}
|
193 |
add_filter( 'all_plugins', 'hmbkp_plugin_row', 10 );
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
function hmbkp_backup_errors_message() {
|
196 |
|
197 |
$message = '';
|
@@ -202,26 +198,4 @@ function hmbkp_backup_errors_message() {
|
|
202 |
|
203 |
return $message;
|
204 |
|
205 |
-
}
|
206 |
-
|
207 |
-
function hmbkp_backup_warnings_message() {
|
208 |
-
|
209 |
-
$message = '';
|
210 |
-
|
211 |
-
foreach ( (array) json_decode( hmbkp_backup_warnings() ) as $key => $errors ) {
|
212 |
-
|
213 |
-
foreach ( $errors as $error ) {
|
214 |
-
|
215 |
-
// Don't show a warning message for php errors in files outside the backupwordpress plugin
|
216 |
-
if ( $key == 'php' && strpos( implode( ':', (array) $error ), HMBKP_PLUGIN_PATH ) === false )
|
217 |
-
continue;
|
218 |
-
|
219 |
-
$message .= '<p><strong>' . $key . '</strong>: <code>' . implode( ':', (array) $error ) . '</code></p>';
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
}
|
224 |
-
|
225 |
-
return $message;
|
226 |
-
|
227 |
}
|
161 |
add_action( 'admin_notices', 'hmbkp_backup_errors_notice' );
|
162 |
|
163 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
}
|
166 |
add_action( 'admin_head', 'hmbkp_admin_notices' );
|
181 |
}
|
182 |
add_filter( 'all_plugins', 'hmbkp_plugin_row', 10 );
|
183 |
|
184 |
+
/**
|
185 |
+
* Parse the json string of errors and
|
186 |
+
* output as a human readable message
|
187 |
+
*
|
188 |
+
* @access public
|
189 |
+
* @return null
|
190 |
+
*/
|
191 |
function hmbkp_backup_errors_message() {
|
192 |
|
193 |
$message = '';
|
198 |
|
199 |
return $message;
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
functions/wp-cli.php
CHANGED
@@ -71,7 +71,7 @@ class BackUpCommand extends WP_CLI_Command {
|
|
71 |
|
72 |
$hm_backup->backup();
|
73 |
|
74 |
-
WP_CLI::line( 'Backup:
|
75 |
|
76 |
// Delete any old backup files
|
77 |
hmbkp_delete_old_backups();
|
@@ -80,7 +80,7 @@ class BackUpCommand extends WP_CLI_Command {
|
|
80 |
WP_CLI::success( 'Backup Complete: ' . HM_Backup::get_instance()->archive_filepath() );
|
81 |
|
82 |
else
|
83 |
-
WP_CLI::
|
84 |
|
85 |
}
|
86 |
|
71 |
|
72 |
$hm_backup->backup();
|
73 |
|
74 |
+
WP_CLI::line( 'Backup: Deleting old backups...' );
|
75 |
|
76 |
// Delete any old backup files
|
77 |
hmbkp_delete_old_backups();
|
80 |
WP_CLI::success( 'Backup Complete: ' . HM_Backup::get_instance()->archive_filepath() );
|
81 |
|
82 |
else
|
83 |
+
WP_CLI::error( 'Backup Failed' );
|
84 |
|
85 |
}
|
86 |
|
hm-backup/hm-backup.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Generic file and database backup class
|
5 |
*
|
6 |
-
* @version 1.
|
7 |
*/
|
8 |
class HM_Backup {
|
9 |
|
@@ -275,6 +275,9 @@ class HM_Backup {
|
|
275 |
// Use mysqldump if we can
|
276 |
if ( $this->mysqldump_command_path ) {
|
277 |
|
|
|
|
|
|
|
278 |
// Path to the mysqldump executable
|
279 |
$cmd = escapeshellarg( $this->mysqldump_command_path );
|
280 |
|
@@ -292,18 +295,23 @@ class HM_Backup {
|
|
292 |
$cmd .= ' -p' . escapeshellarg( DB_PASSWORD );
|
293 |
|
294 |
// Set the host
|
295 |
-
$cmd .= ' -h ' . escapeshellarg(
|
|
|
|
|
|
|
|
|
296 |
|
297 |
-
//
|
298 |
$cmd .= ' -r ' . escapeshellarg( $this->database_dump_filepath() );
|
299 |
|
300 |
// The database we're dumping
|
301 |
$cmd .= ' ' . escapeshellarg( DB_NAME );
|
302 |
|
303 |
-
//
|
304 |
$cmd .= ' 2>&1';
|
305 |
|
306 |
-
|
|
|
307 |
|
308 |
}
|
309 |
|
@@ -323,6 +331,8 @@ class HM_Backup {
|
|
323 |
*/
|
324 |
public function mysqldump_fallback() {
|
325 |
|
|
|
|
|
326 |
$this->mysqldump_method = 'mysqldump_fallback';
|
327 |
|
328 |
$this->db = mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD );
|
@@ -401,15 +411,15 @@ class HM_Backup {
|
|
401 |
|
402 |
// Zip up $this->root with excludes
|
403 |
if ( ! $this->database_only && $this->exclude_string( 'zip' ) )
|
404 |
-
$this->warning(
|
405 |
|
406 |
// Zip up $this->root without excludes
|
407 |
elseif ( ! $this->database_only )
|
408 |
-
$this->warning(
|
409 |
|
410 |
// Add the database dump to the archive
|
411 |
if ( ! $this->files_only )
|
412 |
-
$this->warning(
|
413 |
|
414 |
$this->check_archive();
|
415 |
|
@@ -424,6 +434,7 @@ class HM_Backup {
|
|
424 |
*/
|
425 |
public function zip_archive() {
|
426 |
|
|
|
427 |
$this->archive_method = 'ziparchive';
|
428 |
|
429 |
$zip = new ZipArchive();
|
@@ -456,10 +467,10 @@ class HM_Backup {
|
|
456 |
$zip->addFile( $this->database_dump_filepath(), $this->database_dump_filename() );
|
457 |
|
458 |
if ( $zip->status )
|
459 |
-
$this->warning(
|
460 |
|
461 |
if ( $zip->statusSys )
|
462 |
-
$this->warning(
|
463 |
|
464 |
$zip->close();
|
465 |
|
@@ -478,6 +489,7 @@ class HM_Backup {
|
|
478 |
*/
|
479 |
public function pcl_zip() {
|
480 |
|
|
|
481 |
$this->archive_method = 'pclzip';
|
482 |
|
483 |
global $_hmbkp_exclude_string;
|
@@ -491,12 +503,12 @@ class HM_Backup {
|
|
491 |
// Zip up everything
|
492 |
if ( ! $this->database_only )
|
493 |
if ( ! $archive->add( $this->root(), PCLZIP_OPT_REMOVE_PATH, $this->root(), PCLZIP_CB_PRE_ADD, 'hmbkp_pclzip_callback' ) )
|
494 |
-
$this->warning(
|
495 |
|
496 |
// Add the database
|
497 |
if ( ! $this->files_only )
|
498 |
if ( ! $archive->add( $this->database_dump_filepath(), PCLZIP_OPT_REMOVE_PATH, $this->path() ) )
|
499 |
-
$this->warning(
|
500 |
|
501 |
unset( $GLOBALS['_hmbkp_exclude_string'] );
|
502 |
|
@@ -520,7 +532,7 @@ class HM_Backup {
|
|
520 |
$this->error( $this->archive_method(), __( 'The backup file was not created', 'hmbkp' ) );
|
521 |
|
522 |
// Verify using the zip command if possible
|
523 |
-
if (
|
524 |
|
525 |
$verify = shell_exec( escapeshellarg( $this->zip_command_path ) . ' -T ' . escapeshellarg( $this->archive_filepath() ) . ' 2> /dev/null' );
|
526 |
|
@@ -529,32 +541,6 @@ class HM_Backup {
|
|
529 |
|
530 |
}
|
531 |
|
532 |
-
/* Comment out for now as causes memory issues on large sites */
|
533 |
-
|
534 |
-
//if ( ! $this->errors() ) {
|
535 |
-
//
|
536 |
-
// // If it's a file backup, get an array of all the files that should have been backed up
|
537 |
-
// if ( ! $this->database_only )
|
538 |
-
// $files = $this->files();
|
539 |
-
//
|
540 |
-
// // Check that the database was backed up
|
541 |
-
// if ( ! $this->files_only )
|
542 |
-
// $files[] = $this->database_dump_filename();
|
543 |
-
//
|
544 |
-
// $this->load_pclzip();
|
545 |
-
//
|
546 |
-
// $archive = new PclZip( $this->archive_filepath() );
|
547 |
-
// $filesystem = $archive->extract( PCLZIP_OPT_EXTRACT_AS_STRING );
|
548 |
-
//
|
549 |
-
// foreach( $filesystem as $file )
|
550 |
-
// $archive_files[] = untrailingslashit( $file['filename'] );
|
551 |
-
//
|
552 |
-
// // Check that the array of files that should have been backed up matches the array of files in the zip
|
553 |
-
// if ( $files !== $archive_files )
|
554 |
-
// $this->error( $this->archive_method(), __( 'Backup file doesn\'t contain the the following files: ', 'hmbkp' ) . implode( ', ', array_diff( $files, $archive_files ) ) );
|
555 |
-
//
|
556 |
-
//}
|
557 |
-
|
558 |
// If there are errors delete the backup file.
|
559 |
if ( $this->errors( $this->archive_method() ) && file_exists( $this->archive_filepath() ) )
|
560 |
unlink( $this->archive_filepath() );
|
@@ -711,7 +697,7 @@ class HM_Backup {
|
|
711 |
|
712 |
// Find the one which works
|
713 |
foreach ( $mysqldump_locations as $location )
|
714 |
-
if ( file_exists( $this->conform_dir( $location ) ) )
|
715 |
return $location;
|
716 |
|
717 |
return '';
|
@@ -740,8 +726,8 @@ class HM_Backup {
|
|
740 |
|
741 |
// Find the one which works
|
742 |
foreach ( $zip_locations as $location )
|
743 |
-
|
744 |
-
|
745 |
|
746 |
return '';
|
747 |
|
@@ -870,6 +856,10 @@ class HM_Backup {
|
|
870 |
if ( in_array( 'shell_exec', array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) )
|
871 |
return false;
|
872 |
|
|
|
|
|
|
|
|
|
873 |
return true;
|
874 |
|
875 |
}
|
@@ -896,6 +886,7 @@ class HM_Backup {
|
|
896 |
return $this->conform_dir( $dir );
|
897 |
|
898 |
return $dir;
|
|
|
899 |
}
|
900 |
|
901 |
/**
|
@@ -1155,6 +1146,32 @@ class HM_Backup {
|
|
1155 |
|
1156 |
}
|
1157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
/**
|
1159 |
* Get the warnings
|
1160 |
*
|
3 |
/**
|
4 |
* Generic file and database backup class
|
5 |
*
|
6 |
+
* @version 1.4
|
7 |
*/
|
8 |
class HM_Backup {
|
9 |
|
275 |
// Use mysqldump if we can
|
276 |
if ( $this->mysqldump_command_path ) {
|
277 |
|
278 |
+
$host = reset( explode( ':', DB_HOST ) );
|
279 |
+
$port = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : '';
|
280 |
+
|
281 |
// Path to the mysqldump executable
|
282 |
$cmd = escapeshellarg( $this->mysqldump_command_path );
|
283 |
|
295 |
$cmd .= ' -p' . escapeshellarg( DB_PASSWORD );
|
296 |
|
297 |
// Set the host
|
298 |
+
$cmd .= ' -h ' . escapeshellarg( $host );
|
299 |
+
|
300 |
+
// Set the port if it was set
|
301 |
+
if ( ! empty( $port ) )
|
302 |
+
$cmd .= ' -P ' . $port;
|
303 |
|
304 |
+
// The file we're saving too
|
305 |
$cmd .= ' -r ' . escapeshellarg( $this->database_dump_filepath() );
|
306 |
|
307 |
// The database we're dumping
|
308 |
$cmd .= ' ' . escapeshellarg( DB_NAME );
|
309 |
|
310 |
+
// Pipe STDERR to STDOUT
|
311 |
$cmd .= ' 2>&1';
|
312 |
|
313 |
+
// Store any returned data in warning
|
314 |
+
$this->warning( $this->mysqldump_method, shell_exec( $cmd ) );
|
315 |
|
316 |
}
|
317 |
|
331 |
*/
|
332 |
public function mysqldump_fallback() {
|
333 |
|
334 |
+
$this->errors_to_warnings( $this->mysqldump_method );
|
335 |
+
|
336 |
$this->mysqldump_method = 'mysqldump_fallback';
|
337 |
|
338 |
$this->db = mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD );
|
411 |
|
412 |
// Zip up $this->root with excludes
|
413 |
if ( ! $this->database_only && $this->exclude_string( 'zip' ) )
|
414 |
+
$this->warning( $this->archive_method, shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' -x ' . $this->exclude_string( 'zip' ) . ' 2>&1' ) );
|
415 |
|
416 |
// Zip up $this->root without excludes
|
417 |
elseif ( ! $this->database_only )
|
418 |
+
$this->warning( $this->archive_method, shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' 2>&1' ) );
|
419 |
|
420 |
// Add the database dump to the archive
|
421 |
if ( ! $this->files_only )
|
422 |
+
$this->warning( $this->archive_method, shell_exec( 'cd ' . escapeshellarg( $this->path() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -uq ' . escapeshellarg( $this->archive_filepath() ) . ' ' . escapeshellarg( $this->database_dump_filename() ) . ' 2>&1' ) );
|
423 |
|
424 |
$this->check_archive();
|
425 |
|
434 |
*/
|
435 |
public function zip_archive() {
|
436 |
|
437 |
+
$this->errors_to_warnings( $this->archive_method );
|
438 |
$this->archive_method = 'ziparchive';
|
439 |
|
440 |
$zip = new ZipArchive();
|
467 |
$zip->addFile( $this->database_dump_filepath(), $this->database_dump_filename() );
|
468 |
|
469 |
if ( $zip->status )
|
470 |
+
$this->warning( $this->archive_method, $zip->status );
|
471 |
|
472 |
if ( $zip->statusSys )
|
473 |
+
$this->warning( $this->archive_method, $zip->statusSys );
|
474 |
|
475 |
$zip->close();
|
476 |
|
489 |
*/
|
490 |
public function pcl_zip() {
|
491 |
|
492 |
+
$this->errors_to_warnings( $this->archive_method );
|
493 |
$this->archive_method = 'pclzip';
|
494 |
|
495 |
global $_hmbkp_exclude_string;
|
503 |
// Zip up everything
|
504 |
if ( ! $this->database_only )
|
505 |
if ( ! $archive->add( $this->root(), PCLZIP_OPT_REMOVE_PATH, $this->root(), PCLZIP_CB_PRE_ADD, 'hmbkp_pclzip_callback' ) )
|
506 |
+
$this->warning( $this->archive_method, $archive->errorInfo( true ) );
|
507 |
|
508 |
// Add the database
|
509 |
if ( ! $this->files_only )
|
510 |
if ( ! $archive->add( $this->database_dump_filepath(), PCLZIP_OPT_REMOVE_PATH, $this->path() ) )
|
511 |
+
$this->warning( $this->archive_method, $archive->errorInfo( true ) );
|
512 |
|
513 |
unset( $GLOBALS['_hmbkp_exclude_string'] );
|
514 |
|
532 |
$this->error( $this->archive_method(), __( 'The backup file was not created', 'hmbkp' ) );
|
533 |
|
534 |
// Verify using the zip command if possible
|
535 |
+
if ( $this->zip_command_path ) {
|
536 |
|
537 |
$verify = shell_exec( escapeshellarg( $this->zip_command_path ) . ' -T ' . escapeshellarg( $this->archive_filepath() ) . ' 2> /dev/null' );
|
538 |
|
541 |
|
542 |
}
|
543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
// If there are errors delete the backup file.
|
545 |
if ( $this->errors( $this->archive_method() ) && file_exists( $this->archive_filepath() ) )
|
546 |
unlink( $this->archive_filepath() );
|
697 |
|
698 |
// Find the one which works
|
699 |
foreach ( $mysqldump_locations as $location )
|
700 |
+
if ( @file_exists( $this->conform_dir( $location ) ) )
|
701 |
return $location;
|
702 |
|
703 |
return '';
|
726 |
|
727 |
// Find the one which works
|
728 |
foreach ( $zip_locations as $location )
|
729 |
+
if ( @file_exists( $this->conform_dir( $location ) ) )
|
730 |
+
return $location;
|
731 |
|
732 |
return '';
|
733 |
|
856 |
if ( in_array( 'shell_exec', array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) )
|
857 |
return false;
|
858 |
|
859 |
+
// Can we issue a simple command
|
860 |
+
if ( ! @shell_exec( 'pwd' ) )
|
861 |
+
return false;
|
862 |
+
|
863 |
return true;
|
864 |
|
865 |
}
|
886 |
return $this->conform_dir( $dir );
|
887 |
|
888 |
return $dir;
|
889 |
+
|
890 |
}
|
891 |
|
892 |
/**
|
1146 |
|
1147 |
}
|
1148 |
|
1149 |
+
/**
|
1150 |
+
* Migrate errors to warnings
|
1151 |
+
*
|
1152 |
+
* @access private
|
1153 |
+
* @param string $context. (default: null)
|
1154 |
+
* @return null
|
1155 |
+
*/
|
1156 |
+
private function errors_to_warnings( $context = null ) {
|
1157 |
+
|
1158 |
+
$errors = empty( $context ) ? $this->errors() : array( $context => $this->errors( $context ) );
|
1159 |
+
|
1160 |
+
if ( empty( $errors ) )
|
1161 |
+
return;
|
1162 |
+
|
1163 |
+
foreach ( $errors as $error_context => $errors )
|
1164 |
+
foreach( $errors as $error )
|
1165 |
+
$this->warning( $error_context, $error );
|
1166 |
+
|
1167 |
+
if ( $context )
|
1168 |
+
unset( $this->errors[$context] );
|
1169 |
+
|
1170 |
+
else
|
1171 |
+
$this->errors = array();
|
1172 |
+
|
1173 |
+
}
|
1174 |
+
|
1175 |
/**
|
1176 |
* Get the warnings
|
1177 |
*
|
plugin.php
CHANGED
@@ -5,7 +5,7 @@ Plugin Name: BackUpWordPress
|
|
5 |
Plugin URI: http://hmn.md/backupwordpress/
|
6 |
Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools → Backups</strong>.
|
7 |
Author: Human Made Limited
|
8 |
-
Version: 1.6.
|
9 |
Author URI: http://hmn.md/
|
10 |
*/
|
11 |
|
5 |
Plugin URI: http://hmn.md/backupwordpress/
|
6 |
Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools → Backups</strong>.
|
7 |
Author: Human Made Limited
|
8 |
+
Version: 1.6.4
|
9 |
Author URI: http://hmn.md/
|
10 |
*/
|
11 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot
|
|
3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 3.3
|
6 |
-
Stable tag: 1.6.
|
7 |
|
8 |
Simple automated back ups of your WordPress powered website.
|
9 |
|
@@ -49,6 +49,8 @@ Backups are stored on your server in `/wp-content/backups`, you can change the d
|
|
49 |
|
50 |
You need to download the latest backup file either by clicking download on the backups page or via `FTP`. `Unzip` the files and upload all the files to your server overwriting your site. You can then import the database using your hosts database management tool (likely `phpMyAdmin`).
|
51 |
|
|
|
|
|
52 |
**Does BackUpWordPress back up the backups directory?**
|
53 |
|
54 |
No.
|
@@ -93,6 +95,16 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
93 |
|
94 |
== Changelog ==
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
#### 1.6.3
|
97 |
|
98 |
* Don't fail archive verification for errors in previous archive methods.
|
3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 3.3
|
6 |
+
Stable tag: 1.6.4
|
7 |
|
8 |
Simple automated back ups of your WordPress powered website.
|
9 |
|
49 |
|
50 |
You need to download the latest backup file either by clicking download on the backups page or via `FTP`. `Unzip` the files and upload all the files to your server overwriting your site. You can then import the database using your hosts database management tool (likely `phpMyAdmin`).
|
51 |
|
52 |
+
See this post for more details http://hmn.md/backupwordpress/
|
53 |
+
|
54 |
**Does BackUpWordPress back up the backups directory?**
|
55 |
|
56 |
No.
|
95 |
|
96 |
== Changelog ==
|
97 |
|
98 |
+
#### 1.6.4
|
99 |
+
|
100 |
+
* Don't show warning message as they cause to much panic.
|
101 |
+
* Move previous methods errors to warnings in fallback methods.
|
102 |
+
* Wrap `.htaccess` rewrite rules in if mod_rewrite check.
|
103 |
+
* Add link to new restore help article to FAQ.
|
104 |
+
* Fix issue that could cause "not using latest stable version" message to show when you were in-fact using the latest version.
|
105 |
+
* Bug fix in `zip command` check that could cause an incorrect zip path to be used.
|
106 |
+
* Detect and pass MySQL port to `mysqldump`.
|
107 |
+
|
108 |
#### 1.6.3
|
109 |
|
110 |
* Don't fail archive verification for errors in previous archive methods.
|