Version Description
Download this release
Release Info
| Developer | willmot |
| Plugin | |
| Version | 1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.4 to 1.1
- admin.actions.php +3 -11
- admin.menus.php +18 -1
- admin.page.php +90 -49
- assets/hmbkp.css +7 -0
- assets/hmbkp.js +8 -2
- functions/backup.files.fallback.functions.php +0 -1
- functions/backup.files.functions.php +6 -43
- functions/backup.functions.php +39 -83
- functions/backup.log.functions.php +0 -59
- functions/backup.mysql.fallback.functions.php +17 -60
- functions/backup.mysql.functions.php +8 -11
- functions/core.functions.php +68 -34
- functions/interface.functions.php +2 -3
- functions/settings.functions.php +33 -15
- plugin.php +39 -15
- readme.txt +22 -3
admin.actions.php
CHANGED
|
@@ -27,17 +27,9 @@ function hmbkp_request_do_backup() {
|
|
| 27 |
if ( !isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_backup_now' || hmbkp_is_in_progress() || !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) )
|
| 28 |
return false;
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
'created' => time()
|
| 34 |
-
);
|
| 35 |
-
|
| 36 |
-
update_option( 'hmbkp_running', microtime( true ) );
|
| 37 |
-
|
| 38 |
-
wp_schedule_single_event( time(), 'hmbkp_schedule_backup_hook', $options );
|
| 39 |
-
|
| 40 |
-
spawn_cron();
|
| 41 |
|
| 42 |
wp_redirect( remove_query_arg( 'action' ) );
|
| 43 |
exit;
|
| 27 |
if ( !isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_backup_now' || hmbkp_is_in_progress() || !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) )
|
| 28 |
return false;
|
| 29 |
|
| 30 |
+
wp_schedule_single_event( time(), 'hmbkp_schedule_single_backup_hook' );
|
| 31 |
+
|
| 32 |
+
wp_cron();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
wp_redirect( remove_query_arg( 'action' ) );
|
| 35 |
exit;
|
admin.menus.php
CHANGED
|
@@ -15,4 +15,21 @@ add_action( 'admin_menu', 'hmbkp_admin_menu' );
|
|
| 15 |
*/
|
| 16 |
function hmbkp_manage_backups() {
|
| 17 |
require_once( HMBKP_PLUGIN_PATH . '/admin.page.php' );
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
*/
|
| 16 |
function hmbkp_manage_backups() {
|
| 17 |
require_once( HMBKP_PLUGIN_PATH . '/admin.page.php' );
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Add a link to the backups page to the plugin action links.
|
| 22 |
+
*
|
| 23 |
+
* @param Array $links
|
| 24 |
+
* @param string $file
|
| 25 |
+
* @return Array $links
|
| 26 |
+
*/
|
| 27 |
+
function hmbkp_plugin_action_link( $links, $file ) {
|
| 28 |
+
|
| 29 |
+
if ( strpos( $file, HMBKP_PLUGIN_SLUG ) !== false )
|
| 30 |
+
array_push( $links, '<a href="tools.php?page=' . HMBKP_PLUGIN_SLUG . '">' . __( 'Backups', 'hmbkp' ) . '</a>' );
|
| 31 |
+
|
| 32 |
+
return $links;
|
| 33 |
+
|
| 34 |
+
}
|
| 35 |
+
add_filter('plugin_action_links', 'hmbkp_plugin_action_link', 10, 2 );
|
admin.page.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
<?php $schedules = get_option( 'hmbkp_schedules' ); ?>
|
| 2 |
-
|
| 3 |
<div class="wrap<?php if ( hmbkp_is_in_progress() ) { ?> hmbkp_running<?php } ?>">
|
| 4 |
|
|
|
|
|
|
|
| 5 |
<h2>
|
| 6 |
|
| 7 |
<?php _e( 'Manage Backups', 'hmbkp' ); ?>
|
|
@@ -10,37 +10,91 @@
|
|
| 10 |
<a class="button add-new-h2" <?php disabled( true ); ?>><img src="<?php echo site_url( 'wp-admin/images/wpspin_light.gif' ); ?>" width="16" height="16" /><?php _e( 'Backup Running', 'hmbkp' ); ?></a>
|
| 11 |
|
| 12 |
<?php elseif ( !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) ) : ?>
|
| 13 |
-
<a class="button add-new-h2" <?php disabled( true ); ?>><?php _e( '
|
| 14 |
|
| 15 |
<?php else : ?>
|
| 16 |
-
<a class="button add-new-h2" href="tools.php?page=<?php echo $_GET['page']; ?>&action=hmbkp_backup_now"><?php _e( '
|
| 17 |
|
| 18 |
<?php endif; ?>
|
| 19 |
|
|
|
|
|
|
|
| 20 |
</h2>
|
| 21 |
|
| 22 |
<?php if ( is_dir( hmbkp_path() ) && is_writable( hmbkp_path() ) ) : ?>
|
| 23 |
|
| 24 |
<p>
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</p>
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
<?php $backup_archives = hmbkp_get_backups();
|
| 30 |
if ( count( $backup_archives ) ) : ?>
|
| 31 |
|
| 32 |
-
<h4><?php _e( 'Completed Backups', 'hmbkp' ); ?></h4>
|
| 33 |
-
|
| 34 |
<table class="widefat" id="hmbkp_manage_backups_table">
|
| 35 |
<thead>
|
| 36 |
<tr>
|
| 37 |
-
<th scope="col"><?php _e( '
|
| 38 |
<th scope="col"><?php _e( 'Size', 'hmbkp' ); ?></th>
|
| 39 |
<th scope="col"><?php _e( 'Actions', 'hmbkp' ); ?></th>
|
| 40 |
</tr>
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
<?php foreach ( (array) $backup_archives as $file ) :
|
| 46 |
|
|
@@ -56,59 +110,46 @@
|
|
| 56 |
|
| 57 |
<?php endif; ?>
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
<p class="howto"><?php printf( _n( '* Only the latest backup is saved.', '* Only the latest %d backups are saved.', (int) get_option( 'hmbkp_max_backups' ), 'hmbkp' ) ); ?></p>
|
| 62 |
-
|
| 63 |
-
<?php endif; ?>
|
| 64 |
-
|
| 65 |
-
<h4><?php _e( 'Compatibility', 'hmbkp' ); ?></h4>
|
| 66 |
|
| 67 |
-
|
| 68 |
-
<p><?php _e( 'You can increase the speed and reliability of your backups by resolving the items below. Your backups will still work fine if you don\'t.', 'hmnkp' ); ?></p>
|
| 69 |
<?php endif; ?>
|
| 70 |
|
| 71 |
-
|
| 72 |
-
<p>✗ <?php printf( __( '%s is disabled which means we have to use the slower PHP fallbacks, you could try contacting yout host and asking them to enable it.', 'hmbkp' ), '<code>shell_exec</code>' ); ?>
|
| 73 |
-
<?php endif; ?>
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
-
<p><?php printf( __( 'You can fix this by adding %s to your %s file. run %s on your server to find the path or ask your server administrator.', 'hmbkp' ), '<code>define( "HMBKP_ZIP_PATH", ' . __( 'path to the zip command', 'hmbkp' ) . ' )</code>', '<code>wp-config.php</code>', '<code>which zip</code>' ); ?></p>
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
<p><?php printf( __( 'You can fix this by adding %s to your %s file. run %s on your server to find the path or ask your server administrator.', 'hmbkp' ), '<code>define( "HMBKP_MYSQLDUMP_PATH", ' . __( 'path to the mysqldump command' ) . ' )</code>', '<code>wp-config.php</code>', '<code>which mysqldump</code>' ); ?></p>
|
| 90 |
-
|
| 91 |
-
<?php else : ?>
|
| 92 |
-
<p>✓ <?php printf( __( 'Your database is being backed up using the %s command.', 'hmbkp' ), '<code>' . hmbkp_mysqldump_path() . '</code>' ); ?></p>
|
| 93 |
-
|
| 94 |
-
<?php endif; ?>
|
| 95 |
|
| 96 |
-
|
|
|
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
<p>✗ <code><?php echo HMBKP_PATH; ?></code><?php printf( __( 'doesn\'t exist or isn\'t writable. your backups will be saved to %s.', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?></p>
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
| 112 |
|
| 113 |
<p class="howto"><?php printf( __( 'If you need help getting things working you are more than welcome to email us at %s and we\'ll do what we can.', 'hmbkp' ), '<a href="mailto:support@humanmade.co.uk">support@humanmade.co.uk</a>' ); ?></p>
|
| 114 |
|
|
|
|
|
|
|
| 1 |
<div class="wrap<?php if ( hmbkp_is_in_progress() ) { ?> hmbkp_running<?php } ?>">
|
| 2 |
|
| 3 |
+
<?php screen_icon( 'tools' ); ?>
|
| 4 |
+
|
| 5 |
<h2>
|
| 6 |
|
| 7 |
<?php _e( 'Manage Backups', 'hmbkp' ); ?>
|
| 10 |
<a class="button add-new-h2" <?php disabled( true ); ?>><img src="<?php echo site_url( 'wp-admin/images/wpspin_light.gif' ); ?>" width="16" height="16" /><?php _e( 'Backup Running', 'hmbkp' ); ?></a>
|
| 11 |
|
| 12 |
<?php elseif ( !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) ) : ?>
|
| 13 |
+
<a class="button add-new-h2" <?php disabled( true ); ?>><?php _e( 'Back Up Now', 'hmbkp' ); ?></a>
|
| 14 |
|
| 15 |
<?php else : ?>
|
| 16 |
+
<a class="button add-new-h2" href="tools.php?page=<?php echo $_GET['page']; ?>&action=hmbkp_backup_now"><?php _e( 'Back Up Now', 'hmbkp' ); ?></a>
|
| 17 |
|
| 18 |
<?php endif; ?>
|
| 19 |
|
| 20 |
+
<a href="#hmbkp_advanced-options" class="button add-new-h2 hmbkp_advanced-options-toggle"><?php _e( 'Advanced Options' ); ?></a>
|
| 21 |
+
|
| 22 |
</h2>
|
| 23 |
|
| 24 |
<?php if ( is_dir( hmbkp_path() ) && is_writable( hmbkp_path() ) ) : ?>
|
| 25 |
|
| 26 |
<p>
|
| 27 |
+
|
| 28 |
+
<?php if ( defined( 'HMBKP_DISABLE_AUTOMATIC_BACKUP' ) && HMBKP_DISABLE_AUTOMATIC_BACKUP && !wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) ) : ?>
|
| 29 |
+
|
| 30 |
+
<?php printf( __( 'Automatic backups are %s.', 'hmbkp' ), '<strong>' . __( 'disabled', 'hmbkp' ) . '</strong>' ); ?>
|
| 31 |
+
|
| 32 |
+
<?php else :
|
| 33 |
+
|
| 34 |
+
if ( ( defined( 'HMBKP_FILES_ONLY' ) && !HMBKP_FILES_ONLY || !defined( 'HMBKP_FILES_ONLY' ) ) && ( defined( 'HMBKP_DATABASE_ONLY' ) && !HMBKP_DATABASE_ONLY || !defined( 'HMBKP_DATABASE_ONLY' ) ) )
|
| 35 |
+
$what_to_backup = '<code>' . __( 'database', 'hmbkp' ) . '</code> ' . __( '&', 'hmbkp' ) . ' <code>' . __( 'files', 'hmbkp' ) . '</code>';
|
| 36 |
+
|
| 37 |
+
elseif( defined( 'HMBKP_DATABASE_ONLY' ) && HMBKP_DATABASE_ONLY )
|
| 38 |
+
$what_to_backup = '<code>' . __( 'database', 'hmbkp' ) . '</code>';
|
| 39 |
+
|
| 40 |
+
else
|
| 41 |
+
$what_to_backup = '<code>' . __( 'files', 'hmbkp' ) . '</code>'; ?>
|
| 42 |
+
|
| 43 |
+
<?php printf( __( 'Your %s will be automatically backed up every day at %s to %s.', 'hmbkp' ), $what_to_backup , '<code title="' . sprintf( __( 'It\'s currently %s on the server.', 'hmbkp' ), date( 'H:i' ) ) . '">' . date( 'H:i', wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) ) . '</code>', '<code>' . trailingslashit( hmbkp_path() ) . '</code>' ); ?>
|
| 44 |
+
|
| 45 |
+
<?php endif; ?>
|
| 46 |
+
|
| 47 |
+
<span class="hmbkp_estimated-size"><?php printf( __( 'Each backup will be approximately %s.', 'hmbkp' ), get_transient( 'hmbkp_estimated_filesize' ) ? '<code>' . hmbkp_calculate() . '</code>' : '<code class="calculate">' . __( 'Calculating Size...', 'hmbkp' ) . '</code>' ); ?></span>
|
| 48 |
+
|
| 49 |
</p>
|
| 50 |
|
| 51 |
+
<?php if ( !hmbkp_shell_exec_available() ) : ?>
|
| 52 |
+
<p>✗ <?php printf( __( '%s is disabled which means we have to use the slower PHP fallbacks, you could try contacting yout host and asking them to enable it.', 'hmbkp' ), '<code>shell_exec</code>' ); ?>
|
| 53 |
+
<?php endif; ?>
|
| 54 |
+
|
| 55 |
+
<?php if ( hmbkp_shell_exec_available() ) : ?>
|
| 56 |
+
|
| 57 |
+
<?php if ( hmbkp_zip_path() && defined( 'HMBKP_DATABASE_ONLY' ) && !HMBKP_DATABASE_ONLY || !defined( 'HMBKP_DATABASE_ONLY' ) ) : ?>
|
| 58 |
+
<p>✓ <?php printf( __( 'Your %s will be backed up using the %s command.', 'hmbkp' ), '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<code>' . hmbkp_zip_path() . '</code>' ); ?></p>
|
| 59 |
+
<?php endif; ?>
|
| 60 |
+
|
| 61 |
+
<?php if ( hmbkp_mysqldump_path() && defined( 'HMBKP_FILES_ONLY' ) && !HMBKP_FILES_ONLY || !defined( 'HMBKP_FILES_ONLY' ) ) : ?>
|
| 62 |
+
<p>✓ <?php printf( __( 'Your %s will be backed up using the %s command.', 'hmbkp' ), '<code>' . __( 'database', 'hmbkp' ) . '</code>', '<code>' . hmbkp_mysqldump_path() . '</code>' ); ?></p>
|
| 63 |
+
<?php endif; ?>
|
| 64 |
+
|
| 65 |
+
<?php endif; ?>
|
| 66 |
+
|
| 67 |
+
<?php if ( defined( 'HMBKP_PATH' ) && HMBKP_PATH ) :
|
| 68 |
+
if ( !is_dir( HMBKP_PATH ) || !is_writable( HMBKP_PATH ) ) : ?>
|
| 69 |
+
<p>✗ <code><?php echo HMBKP_PATH; ?></code><?php printf( __( 'doesn\'t exist or isn\'t writable. your backups will be saved to %s.', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?>.</p>
|
| 70 |
+
|
| 71 |
+
<?php else : ?>
|
| 72 |
+
<p>✓ <?php printf( __( 'Your backups will be saved to %s.', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?></p>
|
| 73 |
+
|
| 74 |
+
<?php endif; ?>
|
| 75 |
+
<?php endif ; ?>
|
| 76 |
+
|
| 77 |
<?php $backup_archives = hmbkp_get_backups();
|
| 78 |
if ( count( $backup_archives ) ) : ?>
|
| 79 |
|
|
|
|
|
|
|
| 80 |
<table class="widefat" id="hmbkp_manage_backups_table">
|
| 81 |
<thead>
|
| 82 |
<tr>
|
| 83 |
+
<th scope="col"><?php _e( 'Completed Backups', 'hmbkp' ); ?></th>
|
| 84 |
<th scope="col"><?php _e( 'Size', 'hmbkp' ); ?></th>
|
| 85 |
<th scope="col"><?php _e( 'Actions', 'hmbkp' ); ?></th>
|
| 86 |
</tr>
|
| 87 |
+
</thead>
|
| 88 |
|
| 89 |
+
<tfoot>
|
| 90 |
+
<tr>
|
| 91 |
+
<th><?php printf( _n( 'Only the most recent backup will be saved.', 'The %d most recent backups will be saved.', hmbkp_max_backups(), 'hmbkp' ), hmbkp_max_backups() ); ?></th>
|
| 92 |
+
<th><?php printf( __( 'Total %s', 'hmbkp' ), hmbkp_total_filesize() ); ?></th>
|
| 93 |
+
<th></th>
|
| 94 |
+
</tr>
|
| 95 |
+
</tfoot>
|
| 96 |
+
|
| 97 |
+
<tbody id="the-list">
|
| 98 |
|
| 99 |
<?php foreach ( (array) $backup_archives as $file ) :
|
| 100 |
|
| 110 |
|
| 111 |
<?php endif; ?>
|
| 112 |
|
| 113 |
+
<?php else : ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
<p><strong><?php _e( 'You need to fix the issues detailed above before BackUpWordPress can start.', 'hmbkp' ); ?></strong></p>
|
|
|
|
| 116 |
<?php endif; ?>
|
| 117 |
|
| 118 |
+
<div id="hmbkp_advanced-options">
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
<h4><?php _e( 'Advanced Options', 'hmbkp' ); ?></h4>
|
| 121 |
|
| 122 |
+
<p><?php printf( __( 'You can %s any of the following %s in your %s to control advanced options.', 'hmbkp' ), '<code>define</code>', '<code>Constants</code>', '<code>wp-config.php</code>' ); ?></p>
|
| 123 |
|
| 124 |
+
<dl>
|
|
|
|
| 125 |
|
| 126 |
+
<dt><code>HMBKP_PATH</code></dt>
|
| 127 |
+
<dd><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?></dd>
|
| 128 |
|
| 129 |
+
<dt><code>HMBKP_MYSQLDUMP_PATH</code></dt>
|
| 130 |
+
<dd><?php printf( __( 'The path to your %s executable. Will be used for the %s part of the backup if available.', 'hmbkp' ), '<code>mysqldump</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>' ); ?></dd>
|
| 131 |
|
| 132 |
+
<dt><code>HMBKP_ZIP_PATH</code></dt>
|
| 133 |
+
<dd><?php printf( __( 'The path to your %s executable. Will be used to zip up your %s if available.', 'hmbkp' ), '<code>zip</code>', '<code>' . __( 'files', 'hmbkp' ) . '</code>' ); ?></dd>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
<dt><code>HMBKP_DISABLE_AUTOMATIC_BACKUP</code></dt>
|
| 136 |
+
<dd><?php _e( 'Completely disables the automatic backup. You can still back up using the "Back Up Now" button.', 'hmbkp' ); ?></dd>
|
| 137 |
|
| 138 |
+
<dt><code>HMBKP_MAX_BACKUPS</code></dt>
|
| 139 |
+
<dd><?php _e( 'Number of backups to keep, older backups will be deleted automatically when a new backup is completed.', 'hmbkp' ); ?></dd>
|
|
|
|
| 140 |
|
| 141 |
+
<dt><code>HMBKP_FILES_ONLY</code></dt>
|
| 142 |
+
<dd><?php printf( __( 'Backup %s only, your %s will %s be backed up.', 'hmbkp' ), '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>', '<strong>' . __( 'not', 'hmbkp' ) . '</strong>' ); ?></dd>
|
| 143 |
|
| 144 |
+
<dt><code>HMBKP_DATABASE_ONLY</code></dt>
|
| 145 |
+
<dd><?php printf( __( 'Backup %s only, your %s will %s be backed up.', 'hmbkp' ), '<code>' . __( 'database', 'hmbkp' ) . '</code>', '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<strong>' . __( 'not', 'hmbkp' ) . '</strong>' ); ?></dd>
|
| 146 |
|
| 147 |
+
<dt><code>HMBKP_DAILY_SCHEDULE_TIME</code></dt>
|
| 148 |
+
<dd><?php printf( __( 'The time that the daily backup should run. Uses 24 hour clock format %s.', 'hmbkp' ), '<code>23:00</code>' ); ?></dd>
|
| 149 |
|
| 150 |
+
</dl>
|
| 151 |
+
|
| 152 |
+
</div>
|
| 153 |
|
| 154 |
<p class="howto"><?php printf( __( 'If you need help getting things working you are more than welcome to email us at %s and we\'ll do what we can.', 'hmbkp' ), '<a href="mailto:support@humanmade.co.uk">support@humanmade.co.uk</a>' ); ?></p>
|
| 155 |
|
assets/hmbkp.css
CHANGED
|
@@ -1,3 +1,10 @@
|
|
| 1 |
.hmbkp_running .add-new-h2 img { margin: 0 3px -4px -9px; opacity: 0.3; }
|
| 2 |
.button.disabled, .button[disabled], .button[disabled="disabled"] { cursor: default; }
|
| 3 |
.button.disabled:active, .button[disabled]:active, .button[disabled="disabled"]:active { background: #F2F2F2 url(../../../../wp-admin/images/white-grad.png) repeat-x; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
.hmbkp_running .add-new-h2 img { margin: 0 3px -4px -9px; opacity: 0.3; }
|
| 2 |
.button.disabled, .button[disabled], .button[disabled="disabled"] { cursor: default; }
|
| 3 |
.button.disabled:active, .button[disabled]:active, .button[disabled="disabled"]:active { background: #F2F2F2 url(../../../../wp-admin/images/white-grad.png) repeat-x; }
|
| 4 |
+
tfoot p { margin: 0; font-weight: normal; }
|
| 5 |
+
#hmbkp_advanced-options { display: none; }
|
| 6 |
+
#hmbkp_advanced-options dl { overflow: hidden; margin: 20px 0; }
|
| 7 |
+
#hmbkp_advanced-options dt { float: left; width: 250px; clear: both; border-top: 1px solid #DFDFDF; padding: 7px 0; }
|
| 8 |
+
#hmbkp_advanced-options dd { color: #666; margin-left: 250px; border-top: 1px solid #DFDFDF; padding: 7px 0; }
|
| 9 |
+
.hmbkp_manage_backups_row .delete { color: #BC0B0B; }
|
| 10 |
+
.hmbkp_manage_backups_row .delete:hover { color: red; }
|
assets/hmbkp.js
CHANGED
|
@@ -6,12 +6,18 @@ jQuery( document ).ready( function( $ ) {
|
|
| 6 |
|
| 7 |
$.get( ajaxurl, { 'action' : 'hmbkp_calculate' },
|
| 8 |
function( data ) {
|
| 9 |
-
$( '.hmbkp_estimated-size
|
| 10 |
-
$( '.hmbkp_estimated-size
|
| 11 |
$( this ).empty().append( data );
|
| 12 |
} ).fadeIn();
|
| 13 |
}
|
| 14 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
} );
|
| 17 |
|
| 6 |
|
| 7 |
$.get( ajaxurl, { 'action' : 'hmbkp_calculate' },
|
| 8 |
function( data ) {
|
| 9 |
+
$( '.hmbkp_estimated-size .calculate' ).removeClass( 'calculating' );
|
| 10 |
+
$( '.hmbkp_estimated-size .calculate' ).fadeOut( function() {
|
| 11 |
$( this ).empty().append( data );
|
| 12 |
} ).fadeIn();
|
| 13 |
}
|
| 14 |
);
|
| 15 |
+
|
| 16 |
+
$( '.hmbkp_advanced-options-toggle' ).click( function() {
|
| 17 |
+
|
| 18 |
+
$( '#hmbkp_advanced-options' ).toggle();
|
| 19 |
+
|
| 20 |
+
} );
|
| 21 |
|
| 22 |
} );
|
| 23 |
|
functions/backup.files.fallback.functions.php
CHANGED
|
@@ -9,7 +9,6 @@
|
|
| 9 |
* @todo support zipArchive
|
| 10 |
* @param string $backup_tmp_dir
|
| 11 |
* @param string $backup_filepath
|
| 12 |
-
* @return void
|
| 13 |
*/
|
| 14 |
function hmbkp_archive_files_fallback( $backup_tmp_dir, $backup_filepath ) {
|
| 15 |
|
| 9 |
* @todo support zipArchive
|
| 10 |
* @param string $backup_tmp_dir
|
| 11 |
* @param string $backup_filepath
|
|
|
|
| 12 |
*/
|
| 13 |
function hmbkp_archive_files_fallback( $backup_tmp_dir, $backup_filepath ) {
|
| 14 |
|
functions/backup.files.functions.php
CHANGED
|
@@ -5,25 +5,13 @@
|
|
| 5 |
* then zip it all up
|
| 6 |
*
|
| 7 |
* @param string $backup_tmp_dir
|
| 8 |
-
* @param array $log
|
| 9 |
-
* @param string $backup_filename
|
| 10 |
-
* @return void
|
| 11 |
*/
|
| 12 |
-
function hmbkp_backup_files( $backup_tmp_dir
|
| 13 |
|
| 14 |
-
$backup_filepath = trailingslashit( hmbkp_path() ) . $backup_filename;
|
| 15 |
$wordpress_files = $backup_tmp_dir . '/wordpress_files';
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
if ( !mkdir( $wordpress_files, 0777 ) )
|
| 20 |
-
$log['logfile'][] = sprintf( __( 'The temporary directory %s could not be created', 'hmbkp' ), $wordpress_files );
|
| 21 |
-
else
|
| 22 |
-
$log['logfile'][] = sprintf( __( 'Temporary directory created', 'hmbkp' ), $wordpress_files );
|
| 23 |
-
|
| 24 |
-
hmbkp_write_log( $log );
|
| 25 |
-
|
| 26 |
-
endif;
|
| 27 |
|
| 28 |
// Copy the whole site to the temporary directory
|
| 29 |
$files = hmbkp_ls( hmbkp_conform_dir( ABSPATH ) );
|
|
@@ -35,13 +23,7 @@ function hmbkp_backup_files( $backup_tmp_dir, $log, $backup_filename ) {
|
|
| 35 |
|
| 36 |
if ( is_dir( $f ) ) :
|
| 37 |
|
| 38 |
-
if (
|
| 39 |
-
|
| 40 |
-
if ( !is_dir( $wordpress_files . hmbkp_conform_dir( $f, true ) ) ) {
|
| 41 |
-
$log['logfile'][] = __( 'Failed to make directory', 'hmbkp' ) . ': ' . $f;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
else
|
| 45 |
$subdirs_created++;
|
| 46 |
|
| 47 |
endif;
|
|
@@ -54,31 +36,13 @@ function hmbkp_backup_files( $backup_tmp_dir, $log, $backup_filename ) {
|
|
| 54 |
unlink( $wordpress_files . hmbkp_conform_dir( $f, true ) );
|
| 55 |
|
| 56 |
// Copy the file
|
| 57 |
-
|
| 58 |
-
$log['logfile'][] = __( 'Failed to copy file', 'hmbkp' ) . ': ' . $f;
|
| 59 |
|
| 60 |
endif;
|
| 61 |
|
| 62 |
$i++;
|
| 63 |
endforeach;
|
| 64 |
|
| 65 |
-
$log['logfile'][] = $subdirs_created . ' ' . __( 'temporary sub-directories copied sucessfully', 'hmbkp' );
|
| 66 |
-
$log['logfile'][] = $files_copied . ' ' . __( 'temporary files copied sucessfully', 'hmbkp' );
|
| 67 |
-
|
| 68 |
-
// Zip up the files
|
| 69 |
-
hmbkp_archive_files( $backup_tmp_dir, $backup_filepath );
|
| 70 |
-
|
| 71 |
-
// Make sure the archive exists
|
| 72 |
-
if ( !file_exists( $backup_filepath ) )
|
| 73 |
-
$log['logfile'][] = __( 'Failed to create backup archive', 'hmbkp' ) . ' ' . $backup_filename;
|
| 74 |
-
|
| 75 |
-
else
|
| 76 |
-
$log['logfile'][] = __( 'Archive created successfully:', 'hmbkp' ) . ' ' . $backup_filename;
|
| 77 |
-
|
| 78 |
-
$log['logfile'][] = count( hmbkp_rmdirtree( $backup_tmp_dir ) ) . ' ' . __( 'Temporary file and directories deleted successfully', 'hmbkp' );
|
| 79 |
-
|
| 80 |
-
hmbkp_write_log( $log );
|
| 81 |
-
|
| 82 |
}
|
| 83 |
|
| 84 |
/**
|
|
@@ -90,7 +54,6 @@ function hmbkp_backup_files( $backup_tmp_dir, $log, $backup_filename ) {
|
|
| 90 |
*
|
| 91 |
* @param string $backup_tmp_dir
|
| 92 |
* @param string $backup_filepath
|
| 93 |
-
* @return void
|
| 94 |
*/
|
| 95 |
function hmbkp_archive_files( $backup_tmp_dir, $backup_filepath ) {
|
| 96 |
|
|
@@ -113,7 +76,7 @@ function hmbkp_archive_files( $backup_tmp_dir, $backup_filepath ) {
|
|
| 113 |
*/
|
| 114 |
function hmbkp_zip_path() {
|
| 115 |
|
| 116 |
-
if ( !hmbkp_shell_exec_available() )
|
| 117 |
return false;
|
| 118 |
|
| 119 |
$path = '';
|
| 5 |
* then zip it all up
|
| 6 |
*
|
| 7 |
* @param string $backup_tmp_dir
|
|
|
|
|
|
|
|
|
|
| 8 |
*/
|
| 9 |
+
function hmbkp_backup_files( $backup_tmp_dir ) {
|
| 10 |
|
|
|
|
| 11 |
$wordpress_files = $backup_tmp_dir . '/wordpress_files';
|
| 12 |
|
| 13 |
+
if ( !is_dir( $wordpress_files ) )
|
| 14 |
+
mkdir( $wordpress_files, 0755 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
// Copy the whole site to the temporary directory
|
| 17 |
$files = hmbkp_ls( hmbkp_conform_dir( ABSPATH ) );
|
| 23 |
|
| 24 |
if ( is_dir( $f ) ) :
|
| 25 |
|
| 26 |
+
if ( mkdir( $wordpress_files . hmbkp_conform_dir( $f, true ), 0755 ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
$subdirs_created++;
|
| 28 |
|
| 29 |
endif;
|
| 36 |
unlink( $wordpress_files . hmbkp_conform_dir( $f, true ) );
|
| 37 |
|
| 38 |
// Copy the file
|
| 39 |
+
copy( $f, $wordpress_files . hmbkp_conform_dir( $f, true ) );
|
|
|
|
| 40 |
|
| 41 |
endif;
|
| 42 |
|
| 43 |
$i++;
|
| 44 |
endforeach;
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
| 54 |
*
|
| 55 |
* @param string $backup_tmp_dir
|
| 56 |
* @param string $backup_filepath
|
|
|
|
| 57 |
*/
|
| 58 |
function hmbkp_archive_files( $backup_tmp_dir, $backup_filepath ) {
|
| 59 |
|
| 76 |
*/
|
| 77 |
function hmbkp_zip_path() {
|
| 78 |
|
| 79 |
+
if ( !hmbkp_shell_exec_available() || ( defined( 'HMBKP_ZIP_PATH' ) && !HMBKP_ZIP_PATH ) )
|
| 80 |
return false;
|
| 81 |
|
| 82 |
$path = '';
|
functions/backup.functions.php
CHANGED
|
@@ -12,34 +12,36 @@
|
|
| 12 |
*/
|
| 13 |
function hmbkp_do_backup() {
|
| 14 |
|
| 15 |
-
$time_start =
|
| 16 |
|
| 17 |
-
$
|
|
|
|
| 18 |
|
| 19 |
-
update_option( 'hmbkp_running', $
|
| 20 |
|
| 21 |
// Raise the memory limit
|
| 22 |
ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
|
| 23 |
-
|
| 24 |
-
// start the log
|
| 25 |
-
$log['logfile'] = array();
|
| 26 |
|
| 27 |
// Create a temporary directory for this backup
|
| 28 |
-
$backup_tmp_dir = hmbkp_create_tmp_dir( $
|
| 29 |
|
| 30 |
// Backup database
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
// Backup files
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
// Delete any old backup files
|
| 37 |
-
hmbkp_delete_old_backups(
|
| 38 |
-
|
| 39 |
-
$log['logfile'][] = sprintf( __( 'Backup done at %d', 'hmbkp' ), hmbkp_timestamp() );
|
| 40 |
-
$log['logfile'][] = sprintf( __( 'Backup was running for %d Seconds', 'hmbkp' ), round( microtime( true ) - $time_start, 2 ) );
|
| 41 |
-
|
| 42 |
-
hmbkp_write_log( $log );
|
| 43 |
|
| 44 |
delete_option( 'hmbkp_running' );
|
| 45 |
|
|
@@ -47,41 +49,22 @@ function hmbkp_do_backup() {
|
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Deletes old backup files
|
| 50 |
-
*
|
| 51 |
-
* @see hmbkp_set_defaults for default number of backups
|
| 52 |
-
* to be kept.
|
| 53 |
*/
|
| 54 |
-
function hmbkp_delete_old_backups(
|
| 55 |
|
| 56 |
$files = hmbkp_get_backups();
|
| 57 |
|
| 58 |
-
if ( count( $files ) <=
|
| 59 |
return;
|
| 60 |
|
| 61 |
-
$
|
| 62 |
-
|
| 63 |
-
foreach ( $files as $key => $f ) :
|
| 64 |
-
|
| 65 |
-
if ( ( $key + 1 ) > get_option( 'hmbkp_max_backups' ) ) :
|
| 66 |
hmbkp_delete_backup( base64_encode( $f['file'] ) );
|
| 67 |
-
$unlinkcount++;
|
| 68 |
-
|
| 69 |
-
endif;
|
| 70 |
-
|
| 71 |
-
endforeach;
|
| 72 |
-
|
| 73 |
-
if ( $unlinkcount )
|
| 74 |
-
$log['logfile'][] = sprintf( __( '%d old backup deleted.', 'hmbkp' ), $unlinkcount );
|
| 75 |
-
|
| 76 |
-
else
|
| 77 |
-
$log['logfile'][] = __( 'No old backups to delete.', 'hmbkp' );
|
| 78 |
|
| 79 |
}
|
| 80 |
|
| 81 |
/**
|
| 82 |
* Returns an array of backup files
|
| 83 |
-
*
|
| 84 |
-
* @todo support when backups directory changes
|
| 85 |
*/
|
| 86 |
function hmbkp_get_backups() {
|
| 87 |
|
|
@@ -114,16 +97,7 @@ function hmbkp_get_backups() {
|
|
| 114 |
}
|
| 115 |
|
| 116 |
/**
|
| 117 |
-
*
|
| 118 |
-
*
|
| 119 |
-
* @param mixed $options
|
| 120 |
-
*/
|
| 121 |
-
function hmbkp_schedule_backup( $options ) {
|
| 122 |
-
hmbkp_do_backup();
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
/**
|
| 126 |
-
* Delete a backup file and it's associated logs
|
| 127 |
*
|
| 128 |
* @param $file base64 encoded filename
|
| 129 |
*/
|
|
@@ -135,48 +109,30 @@ function hmbkp_delete_backup( $file ) {
|
|
| 135 |
if ( strpos( $file, hmbkp_path() ) !== false || strpos( $file, WP_CONTENT_DIR . '/backups' ) !== false )
|
| 136 |
unlink( $file );
|
| 137 |
|
| 138 |
-
// Handle changed backups directory
|
| 139 |
-
$log = str_replace( hmbkp_path(), trailingslashit( hmbkp_path() ) . 'logs/', $file );
|
| 140 |
-
$log = str_replace( WP_CONTENT_DIR . '/backups', WP_CONTENT_DIR . '/backups/logs/', $log );
|
| 141 |
-
|
| 142 |
-
// Delete the log
|
| 143 |
-
if ( file_exists( $log . '.log' ) )
|
| 144 |
-
unlink( $log . '.log' );
|
| 145 |
-
|
| 146 |
-
// Delete the mysqldump log
|
| 147 |
-
if ( file_exists( str_replace( '.zip', '', $log ) . '-mysqldump.log' ) )
|
| 148 |
-
unlink( str_replace( '.zip', '', $log ) . '-mysqldump.log' );
|
| 149 |
-
|
| 150 |
}
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
$log['logfile'][] = __( 'Backup starting at', 'hmbkp' ) . ' ' . hmbkp_timestamp() ;
|
| 159 |
-
|
| 160 |
-
// Create the temp backup directory
|
| 161 |
-
if ( !is_dir( $backup_tmp_dir ) ) :
|
| 162 |
-
|
| 163 |
-
if ( !mkdir( $backup_tmp_dir, 0777 ) )
|
| 164 |
-
$log['logfile'][] = sprintf( __( 'Backup temporary directory %s could not be created', 'hmbkp' ), $backup_tmp_dir );
|
| 165 |
-
|
| 166 |
-
else
|
| 167 |
-
$log['logfile'][] = sprintf( __( 'Backup temporary directory %s created', 'hmbkp' ), $backup_tmp_dir );
|
| 168 |
-
|
| 169 |
-
else :
|
| 170 |
-
$log['logfile'][] = sprintf( __( 'Backup temporary directory %s exists.', 'hmbkp' ), $backup_tmp_dir );
|
| 171 |
-
|
| 172 |
-
endif;
|
| 173 |
-
|
| 174 |
-
hmbkp_write_log( $log );
|
| 175 |
|
| 176 |
return $backup_tmp_dir;
|
| 177 |
|
| 178 |
}
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
function hmbkp_is_in_progress() {
|
| 181 |
return (bool) get_option( 'hmbkp_running' );
|
| 182 |
}
|
| 12 |
*/
|
| 13 |
function hmbkp_do_backup() {
|
| 14 |
|
| 15 |
+
$time_start = date( 'Y-m-d-H-i-s' );
|
| 16 |
|
| 17 |
+
$filename = $time_start . '.zip';
|
| 18 |
+
$filepath = trailingslashit( hmbkp_path() ) . $filename;
|
| 19 |
|
| 20 |
+
update_option( 'hmbkp_running', $time_start );
|
| 21 |
|
| 22 |
// Raise the memory limit
|
| 23 |
ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
|
| 24 |
+
set_time_limit( 300 );
|
|
|
|
|
|
|
| 25 |
|
| 26 |
// Create a temporary directory for this backup
|
| 27 |
+
$backup_tmp_dir = hmbkp_create_tmp_dir( $time_start );
|
| 28 |
|
| 29 |
// Backup database
|
| 30 |
+
if ( ( defined( 'HMBKP_FILES_ONLY' ) && !HMBKP_FILES_ONLY ) || !defined( 'HMBKP_FILES_ONLY' ) )
|
| 31 |
+
hmbkp_backup_mysql( $backup_tmp_dir );
|
| 32 |
|
| 33 |
// Backup files
|
| 34 |
+
if ( ( defined( 'HMBKP_DATABASE_ONLY' ) && !HMBKP_DATABASE_ONLY ) || !defined( 'HMBKP_DATABASE_ONLY' ) )
|
| 35 |
+
hmbkp_backup_files( $backup_tmp_dir );
|
| 36 |
+
|
| 37 |
+
// Zip up the files
|
| 38 |
+
hmbkp_archive_files( $backup_tmp_dir, $filepath );
|
| 39 |
+
|
| 40 |
+
// Remove the temporary directory
|
| 41 |
+
hmbkp_rmdirtree( $backup_tmp_dir );
|
| 42 |
+
|
| 43 |
// Delete any old backup files
|
| 44 |
+
hmbkp_delete_old_backups();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
delete_option( 'hmbkp_running' );
|
| 47 |
|
| 49 |
|
| 50 |
/**
|
| 51 |
* Deletes old backup files
|
|
|
|
|
|
|
|
|
|
| 52 |
*/
|
| 53 |
+
function hmbkp_delete_old_backups() {
|
| 54 |
|
| 55 |
$files = hmbkp_get_backups();
|
| 56 |
|
| 57 |
+
if ( count( $files ) <= hmbkp_max_backups() )
|
| 58 |
return;
|
| 59 |
|
| 60 |
+
foreach ( $files as $key => $f )
|
| 61 |
+
if ( ( $key + 1 ) > hmbkp_max_backups() )
|
|
|
|
|
|
|
|
|
|
| 62 |
hmbkp_delete_backup( base64_encode( $f['file'] ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
}
|
| 65 |
|
| 66 |
/**
|
| 67 |
* Returns an array of backup files
|
|
|
|
|
|
|
| 68 |
*/
|
| 69 |
function hmbkp_get_backups() {
|
| 70 |
|
| 97 |
}
|
| 98 |
|
| 99 |
/**
|
| 100 |
+
* Delete a backup file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
*
|
| 102 |
* @param $file base64 encoded filename
|
| 103 |
*/
|
| 109 |
if ( strpos( $file, hmbkp_path() ) !== false || strpos( $file, WP_CONTENT_DIR . '/backups' ) !== false )
|
| 110 |
unlink( $file );
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
| 113 |
|
| 114 |
+
/**
|
| 115 |
+
* Create and return the path to the tmp directory
|
| 116 |
+
*
|
| 117 |
+
* @param string $date
|
| 118 |
+
* @return string
|
| 119 |
+
*/
|
| 120 |
+
function hmbkp_create_tmp_dir( $date ) {
|
| 121 |
|
| 122 |
+
$backup_tmp_dir = trailingslashit( hmbkp_path() ) . $date;
|
| 123 |
+
|
| 124 |
+
if ( !is_dir( $backup_tmp_dir ) )
|
| 125 |
+
mkdir( $backup_tmp_dir );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
return $backup_tmp_dir;
|
| 128 |
|
| 129 |
}
|
| 130 |
|
| 131 |
+
/**
|
| 132 |
+
* Check if a backup is running
|
| 133 |
+
*
|
| 134 |
+
* @return bool
|
| 135 |
+
*/
|
| 136 |
function hmbkp_is_in_progress() {
|
| 137 |
return (bool) get_option( 'hmbkp_running' );
|
| 138 |
}
|
functions/backup.log.functions.php
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* hmbkp_write_log function.
|
| 5 |
-
*
|
| 6 |
-
* @param array $log
|
| 7 |
-
* @param string $return. (default: "")
|
| 8 |
-
*/
|
| 9 |
-
function hmbkp_write_log( &$log ) {
|
| 10 |
-
|
| 11 |
-
global $wp_version;
|
| 12 |
-
|
| 13 |
-
$time = hmbkp_timestamp();
|
| 14 |
-
|
| 15 |
-
if ( !is_array( $log ) )
|
| 16 |
-
return;
|
| 17 |
-
|
| 18 |
-
$logdir = trailingslashit( hmbkp_path() ) . 'logs';
|
| 19 |
-
|
| 20 |
-
if ( !is_dir( $logdir ) )
|
| 21 |
-
mkdir( $logdir, 0755 );
|
| 22 |
-
|
| 23 |
-
$logname = $logdir . '/' . $log['filename'] . '.log';
|
| 24 |
-
$logfile = '';
|
| 25 |
-
|
| 26 |
-
if ( !file_exists( $logname ) ) :
|
| 27 |
-
|
| 28 |
-
// Write some environmental information for debugging purposes
|
| 29 |
-
$logfile .= "WordPress Version: " . $wp_version . "\n";
|
| 30 |
-
|
| 31 |
-
endif;
|
| 32 |
-
|
| 33 |
-
if ( is_array( $log['logfile'] ) ) :
|
| 34 |
-
|
| 35 |
-
foreach ( $log['logfile'] as $l ) :
|
| 36 |
-
|
| 37 |
-
if ( is_array( $l ) )
|
| 38 |
-
$l = serialize( $l );
|
| 39 |
-
|
| 40 |
-
$logfile .= "## " . hmbkp_timestamp() . ' : ' . $l . "\n";
|
| 41 |
-
|
| 42 |
-
endforeach;
|
| 43 |
-
|
| 44 |
-
// Write the log
|
| 45 |
-
if ( !$handle = fopen( $logname, 'a' ) )
|
| 46 |
-
error_log( 'Logfile could not be opened for writing: ' . $logname );
|
| 47 |
-
|
| 48 |
-
if ( !fwrite( $handle, $logfile ) )
|
| 49 |
-
error_log( 'Logfile not writable: ' . $logname );
|
| 50 |
-
|
| 51 |
-
fclose( $handle );
|
| 52 |
-
|
| 53 |
-
$log['logfile'] = array();
|
| 54 |
-
|
| 55 |
-
return true;
|
| 56 |
-
|
| 57 |
-
endif;
|
| 58 |
-
|
| 59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions/backup.mysql.fallback.functions.php
CHANGED
|
@@ -7,7 +7,6 @@
|
|
| 7 |
*
|
| 8 |
* @access public
|
| 9 |
* @param mixed $a_name
|
| 10 |
-
* @return void
|
| 11 |
*/
|
| 12 |
function hmbkp_backquote( $a_name ) {
|
| 13 |
|
|
@@ -45,10 +44,10 @@ function hmbkp_backquote( $a_name ) {
|
|
| 45 |
* @param string $path
|
| 46 |
* @param mixed $sql_file
|
| 47 |
* @param mixed $table
|
| 48 |
-
* @param mixed $log
|
| 49 |
-
* @return void
|
| 50 |
*/
|
| 51 |
-
function hmbkp_make_sql( $path, $sql_file, $table
|
|
|
|
|
|
|
| 52 |
|
| 53 |
// Add SQL statement to drop existing table
|
| 54 |
$sql_file = "\n";
|
|
@@ -71,13 +70,10 @@ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
|
|
| 71 |
|
| 72 |
// Get table structure
|
| 73 |
$query = 'SHOW CREATE TABLE ' . hmbkp_backquote( $table );
|
| 74 |
-
$result = mysql_query( $query, $
|
| 75 |
|
| 76 |
-
if ( $result
|
| 77 |
-
$log['logfile'][] = __( 'Error getting table structure of ', 'hmbkp' ) . $table . '! ' . mysql_errno() . ': ' . mysql_error();
|
| 78 |
-
hmbkp_write_log( $log );
|
| 79 |
|
| 80 |
-
else :
|
| 81 |
if ( mysql_num_rows( $result ) > 0 ) :
|
| 82 |
$sql_create_arr = mysql_fetch_array( $result );
|
| 83 |
$sql_file .= $sql_create_arr[1];
|
|
@@ -92,13 +88,9 @@ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
|
|
| 92 |
|
| 93 |
// Get table contents
|
| 94 |
$query = 'SELECT * FROM ' . hmbkp_backquote( $table );
|
| 95 |
-
$result = mysql_query( $query, $
|
| 96 |
|
| 97 |
-
if ( $result
|
| 98 |
-
$log['logfile'][] = __( 'Error getting records of ', 'hmbkp' ) . $table . '! ' . mysql_errno() . ': ' . mysql_error();
|
| 99 |
-
hmbkp_write_log( $log );
|
| 100 |
-
|
| 101 |
-
else :
|
| 102 |
$fields_cnt = mysql_num_fields( $result );
|
| 103 |
$rows_cnt = mysql_num_rows( $result );
|
| 104 |
endif;
|
|
@@ -158,7 +150,7 @@ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
|
|
| 158 |
// write the rows in batches of 100
|
| 159 |
if ( $batch_write == 100 ) :
|
| 160 |
$batch_write = 0;
|
| 161 |
-
hmbkp_write_sql( $path, $sql_file
|
| 162 |
$sql_file = '';
|
| 163 |
endif;
|
| 164 |
|
|
@@ -177,7 +169,7 @@ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
|
|
| 177 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 178 |
$sql_file .= "\n";
|
| 179 |
|
| 180 |
-
hmbkp_write_sql( $path, $sql_file
|
| 181 |
|
| 182 |
}
|
| 183 |
|
|
@@ -190,7 +182,6 @@ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
|
|
| 190 |
* @access public
|
| 191 |
* @param string $a_string. (default: '')
|
| 192 |
* @param bool $is_like. (default: false)
|
| 193 |
-
* @return void
|
| 194 |
*/
|
| 195 |
function hmbkp_sql_addslashes( $a_string = '', $is_like = false ) {
|
| 196 |
|
|
@@ -210,29 +201,18 @@ function hmbkp_sql_addslashes( $a_string = '', $is_like = false ) {
|
|
| 210 |
*
|
| 211 |
* @access public
|
| 212 |
* @param mixed $path
|
| 213 |
-
* @param mixed $log
|
| 214 |
-
* @return void
|
| 215 |
*/
|
| 216 |
-
function hmbkp_backup_mysql_fallback( $path
|
| 217 |
|
| 218 |
-
|
| 219 |
-
$log['logfile'][] = __( 'Could not connect to MySQL server! ', 'hmbkp' ) . mysql_error();
|
| 220 |
-
hmbkp_write_log( $log );
|
| 221 |
-
endif;
|
| 222 |
|
| 223 |
-
$
|
| 224 |
-
hmbkp_write_log( $log );
|
| 225 |
|
| 226 |
-
mysql_select_db( DB_NAME, $
|
| 227 |
|
| 228 |
// Begin new backup of MySql
|
| 229 |
$tables = mysql_list_tables( DB_NAME );
|
| 230 |
|
| 231 |
-
if ( !isset($tables) > 0 ) :
|
| 232 |
-
$log['logfile'][] = __( 'Could not select db ', 'hmbkp') . DB_NAME;
|
| 233 |
-
hmbkp_write_log( $log );
|
| 234 |
-
endif;
|
| 235 |
-
|
| 236 |
$sql_file = "# WordPress : " . get_bloginfo( 'url' ) . " MySQL database backup\n";
|
| 237 |
$sql_file .= "#\n";
|
| 238 |
$sql_file .= "# Generated: " . date( 'l j. F Y H:i T' ) . "\n";
|
|
@@ -252,20 +232,10 @@ function hmbkp_backup_mysql_fallback( $path, $log ) {
|
|
| 252 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 253 |
$sql_file .= "# Table: " . hmbkp_backquote( $curr_table ) . "\n";
|
| 254 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 255 |
-
hmbkp_make_sql( $path, $sql_file, $curr_table
|
| 256 |
|
| 257 |
-
$log['logfile'][] = 'sql-dump for ' . $curr_table . ' created';
|
| 258 |
-
hmbkp_write_log( $log );
|
| 259 |
endfor;
|
| 260 |
|
| 261 |
-
if ( !file_exists( $path . '/wordpress.sql' ) )
|
| 262 |
-
$log['logfile'][] = __( 'SQL Dump could not be created.', 'hmbkp' );
|
| 263 |
-
|
| 264 |
-
else
|
| 265 |
-
$log['logfile'][] = __( 'SQL Dump created.', 'hmbkp' );
|
| 266 |
-
|
| 267 |
-
hmbkp_write_log( $log );
|
| 268 |
-
|
| 269 |
}
|
| 270 |
|
| 271 |
/**
|
|
@@ -273,36 +243,23 @@ function hmbkp_backup_mysql_fallback( $path, $log ) {
|
|
| 273 |
*
|
| 274 |
* @param mixed $sqldir
|
| 275 |
* @param mixed $sql
|
| 276 |
-
* @param mixed $log
|
| 277 |
*/
|
| 278 |
-
function hmbkp_write_sql( $sqldir, $sql
|
| 279 |
|
| 280 |
$sqlname = $sqldir . '/wordpress.sql';
|
| 281 |
|
| 282 |
// Actually write the sql file
|
| 283 |
if ( is_writable( $sqlname ) || !file_exists( $sqlname ) ) :
|
| 284 |
|
| 285 |
-
if ( !$handle = fopen( $sqlname, 'a' ) )
|
| 286 |
-
$log['logfile'][] = __( 'SQLfile could not be opened for writing: ', 'hmbkp' ) . $sqlname;
|
| 287 |
-
hmbkp_write_log( $log );
|
| 288 |
return;
|
| 289 |
-
endif;
|
| 290 |
|
| 291 |
-
if ( !fwrite( $handle, $sql ) )
|
| 292 |
-
$log['logfile'][] = __( 'SQLfile not writable: ', 'hmbkp' ) . $sqlname;
|
| 293 |
-
hmbkp_write_log( $log );
|
| 294 |
return;
|
| 295 |
-
endif;
|
| 296 |
|
| 297 |
-
$log['logfile'][] = __( 'successfully written to SQLfile: ', 'hmbkp' ) . $sqlname;
|
| 298 |
-
hmbkp_write_log( $log );
|
| 299 |
fclose( $handle );
|
| 300 |
|
| 301 |
return true;
|
| 302 |
|
| 303 |
-
else :
|
| 304 |
-
$log['logfile'][] = __( 'SQLfile not writable: ', 'hmbkp' ) . $sqlname;
|
| 305 |
-
hmbkp_write_log( $log );
|
| 306 |
-
|
| 307 |
endif;
|
| 308 |
}
|
| 7 |
*
|
| 8 |
* @access public
|
| 9 |
* @param mixed $a_name
|
|
|
|
| 10 |
*/
|
| 11 |
function hmbkp_backquote( $a_name ) {
|
| 12 |
|
| 44 |
* @param string $path
|
| 45 |
* @param mixed $sql_file
|
| 46 |
* @param mixed $table
|
|
|
|
|
|
|
| 47 |
*/
|
| 48 |
+
function hmbkp_make_sql( $path, $sql_file, $table ) {
|
| 49 |
+
|
| 50 |
+
global $hmbkp_db_connect;
|
| 51 |
|
| 52 |
// Add SQL statement to drop existing table
|
| 53 |
$sql_file = "\n";
|
| 70 |
|
| 71 |
// Get table structure
|
| 72 |
$query = 'SHOW CREATE TABLE ' . hmbkp_backquote( $table );
|
| 73 |
+
$result = mysql_query( $query, $hmbkp_db_connect );
|
| 74 |
|
| 75 |
+
if ( $result ) :
|
|
|
|
|
|
|
| 76 |
|
|
|
|
| 77 |
if ( mysql_num_rows( $result ) > 0 ) :
|
| 78 |
$sql_create_arr = mysql_fetch_array( $result );
|
| 79 |
$sql_file .= $sql_create_arr[1];
|
| 88 |
|
| 89 |
// Get table contents
|
| 90 |
$query = 'SELECT * FROM ' . hmbkp_backquote( $table );
|
| 91 |
+
$result = mysql_query( $query, $hmbkp_db_connect );
|
| 92 |
|
| 93 |
+
if ( $result ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
$fields_cnt = mysql_num_fields( $result );
|
| 95 |
$rows_cnt = mysql_num_rows( $result );
|
| 96 |
endif;
|
| 150 |
// write the rows in batches of 100
|
| 151 |
if ( $batch_write == 100 ) :
|
| 152 |
$batch_write = 0;
|
| 153 |
+
hmbkp_write_sql( $path, $sql_file );
|
| 154 |
$sql_file = '';
|
| 155 |
endif;
|
| 156 |
|
| 169 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 170 |
$sql_file .= "\n";
|
| 171 |
|
| 172 |
+
hmbkp_write_sql( $path, $sql_file );
|
| 173 |
|
| 174 |
}
|
| 175 |
|
| 182 |
* @access public
|
| 183 |
* @param string $a_string. (default: '')
|
| 184 |
* @param bool $is_like. (default: false)
|
|
|
|
| 185 |
*/
|
| 186 |
function hmbkp_sql_addslashes( $a_string = '', $is_like = false ) {
|
| 187 |
|
| 201 |
*
|
| 202 |
* @access public
|
| 203 |
* @param mixed $path
|
|
|
|
|
|
|
| 204 |
*/
|
| 205 |
+
function hmbkp_backup_mysql_fallback( $path ) {
|
| 206 |
|
| 207 |
+
global $hmbkp_db_connect;
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
+
$hmbkp_db_connect = @mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD );
|
|
|
|
| 210 |
|
| 211 |
+
mysql_select_db( DB_NAME, $hmbkp_db_connect );
|
| 212 |
|
| 213 |
// Begin new backup of MySql
|
| 214 |
$tables = mysql_list_tables( DB_NAME );
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
$sql_file = "# WordPress : " . get_bloginfo( 'url' ) . " MySQL database backup\n";
|
| 217 |
$sql_file .= "#\n";
|
| 218 |
$sql_file .= "# Generated: " . date( 'l j. F Y H:i T' ) . "\n";
|
| 232 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 233 |
$sql_file .= "# Table: " . hmbkp_backquote( $curr_table ) . "\n";
|
| 234 |
$sql_file .= "# --------------------------------------------------------\n";
|
| 235 |
+
hmbkp_make_sql( $path, $sql_file, $curr_table );
|
| 236 |
|
|
|
|
|
|
|
| 237 |
endfor;
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
/**
|
| 243 |
*
|
| 244 |
* @param mixed $sqldir
|
| 245 |
* @param mixed $sql
|
|
|
|
| 246 |
*/
|
| 247 |
+
function hmbkp_write_sql( $sqldir, $sql ) {
|
| 248 |
|
| 249 |
$sqlname = $sqldir . '/wordpress.sql';
|
| 250 |
|
| 251 |
// Actually write the sql file
|
| 252 |
if ( is_writable( $sqlname ) || !file_exists( $sqlname ) ) :
|
| 253 |
|
| 254 |
+
if ( !$handle = fopen( $sqlname, 'a' ) )
|
|
|
|
|
|
|
| 255 |
return;
|
|
|
|
| 256 |
|
| 257 |
+
if ( !fwrite( $handle, $sql ) )
|
|
|
|
|
|
|
| 258 |
return;
|
|
|
|
| 259 |
|
|
|
|
|
|
|
| 260 |
fclose( $handle );
|
| 261 |
|
| 262 |
return true;
|
| 263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
endif;
|
| 265 |
}
|
functions/backup.mysql.functions.php
CHANGED
|
@@ -7,26 +7,23 @@
|
|
| 7 |
* if not.
|
| 8 |
*
|
| 9 |
* @param string $backup_tmp_dir
|
| 10 |
-
* @param array $log
|
| 11 |
-
* @return void
|
| 12 |
*/
|
| 13 |
-
function hmbkp_backup_mysql( $backup_tmp_dir
|
| 14 |
|
| 15 |
// Use mysqldump if we can
|
| 16 |
if ( hmbkp_mysqldump_path() )
|
| 17 |
shell_exec(
|
| 18 |
escapeshellarg( hmbkp_mysqldump_path() )
|
| 19 |
. ' --no-create-db '
|
| 20 |
-
.' -u ' . escapeshellarg( DB_USER )
|
| 21 |
-
.' -p' . escapeshellarg( DB_PASSWORD )
|
| 22 |
-
.' -h ' . escapeshellarg( DB_HOST )
|
| 23 |
-
.' -r ' . escapeshellarg( $backup_tmp_dir . '/wordpress.sql' ) . ' ' . escapeshellarg( DB_NAME )
|
| 24 |
-
. ' 1> ' . escapeshellarg( str_replace( hmbkp_path(), trailingslashit( hmbkp_path() ) . 'logs/', $backup_tmp_dir ) . '-mysqldump.log' ) .' 2>&1'
|
| 25 |
);
|
| 26 |
|
| 27 |
// Fallback to using PHP if not
|
| 28 |
else
|
| 29 |
-
hmbkp_backup_mysql_fallback( $backup_tmp_dir
|
| 30 |
|
| 31 |
}
|
| 32 |
|
|
@@ -40,7 +37,7 @@ function hmbkp_backup_mysql( $backup_tmp_dir, $log ) {
|
|
| 40 |
*/
|
| 41 |
function hmbkp_mysqldump_path() {
|
| 42 |
|
| 43 |
-
if ( !hmbkp_shell_exec_available() )
|
| 44 |
return false;
|
| 45 |
|
| 46 |
$path = '';
|
|
@@ -76,7 +73,7 @@ function hmbkp_mysqldump_path() {
|
|
| 76 |
endif;
|
| 77 |
|
| 78 |
// Check again incase the saved path has stopped working for some reason
|
| 79 |
-
if (
|
| 80 |
delete_option( 'hmbkp_mysqldump_path' );
|
| 81 |
return hmbkp_mysqldump_path();
|
| 82 |
|
| 7 |
* if not.
|
| 8 |
*
|
| 9 |
* @param string $backup_tmp_dir
|
|
|
|
|
|
|
| 10 |
*/
|
| 11 |
+
function hmbkp_backup_mysql( $backup_tmp_dir ) {
|
| 12 |
|
| 13 |
// Use mysqldump if we can
|
| 14 |
if ( hmbkp_mysqldump_path() )
|
| 15 |
shell_exec(
|
| 16 |
escapeshellarg( hmbkp_mysqldump_path() )
|
| 17 |
. ' --no-create-db '
|
| 18 |
+
. ' -u ' . escapeshellarg( DB_USER )
|
| 19 |
+
. ' -p' . escapeshellarg( DB_PASSWORD )
|
| 20 |
+
. ' -h ' . escapeshellarg( DB_HOST )
|
| 21 |
+
. ' -r ' . escapeshellarg( $backup_tmp_dir . '/wordpress.sql' ) . ' ' . escapeshellarg( DB_NAME )
|
|
|
|
| 22 |
);
|
| 23 |
|
| 24 |
// Fallback to using PHP if not
|
| 25 |
else
|
| 26 |
+
hmbkp_backup_mysql_fallback( $backup_tmp_dir );
|
| 27 |
|
| 28 |
}
|
| 29 |
|
| 37 |
*/
|
| 38 |
function hmbkp_mysqldump_path() {
|
| 39 |
|
| 40 |
+
if ( !hmbkp_shell_exec_available() || ( defined( 'HMBKP_MYSQLDUMP_PATH' ) && !HMBKP_MYSQLDUMP_PATH ) )
|
| 41 |
return false;
|
| 42 |
|
| 43 |
$path = '';
|
| 73 |
endif;
|
| 74 |
|
| 75 |
// Check again incase the saved path has stopped working for some reason
|
| 76 |
+
if ( !shell_exec( 'which ' . $path ) ) :
|
| 77 |
delete_option( 'hmbkp_mysqldump_path' );
|
| 78 |
return hmbkp_mysqldump_path();
|
| 79 |
|
functions/core.functions.php
CHANGED
|
@@ -2,25 +2,21 @@
|
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Setup the default options on plugin activation
|
| 5 |
-
*
|
| 6 |
-
* @return void
|
| 7 |
*/
|
| 8 |
function hmbkp_activate() {
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Cleanup on plugin deactivation
|
| 15 |
*
|
| 16 |
* Removes options and clears all cron schedules
|
| 17 |
-
*
|
| 18 |
-
* @todo remove all hmbkp_ options
|
| 19 |
-
* @return void
|
| 20 |
*/
|
| 21 |
function hmbkp_deactivate() {
|
| 22 |
|
| 23 |
-
//
|
| 24 |
$options = array(
|
| 25 |
'hmbkp_zip_path',
|
| 26 |
'hmbkp_mysqldump_path',
|
|
@@ -34,9 +30,9 @@ function hmbkp_deactivate() {
|
|
| 34 |
foreach ( $options as $option )
|
| 35 |
delete_option( $option );
|
| 36 |
|
| 37 |
-
|
| 38 |
-
// Clear crons
|
| 39 |
wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' );
|
|
|
|
| 40 |
|
| 41 |
}
|
| 42 |
|
|
@@ -44,13 +40,21 @@ function hmbkp_deactivate() {
|
|
| 44 |
/**
|
| 45 |
* Handles anything that needs to be
|
| 46 |
* done when the plugin is updated
|
| 47 |
-
*
|
| 48 |
-
* @return void
|
| 49 |
*/
|
| 50 |
function hmbkp_update() {
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
// Update from backUpWordPress
|
| 56 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
|
@@ -91,6 +95,9 @@ function hmbkp_update() {
|
|
| 91 |
|
| 92 |
endif;
|
| 93 |
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
/**
|
|
@@ -107,7 +114,7 @@ function hmbkp_timestamp() {
|
|
| 107 |
*
|
| 108 |
* @param string $dir
|
| 109 |
* @param bool $rel. (default: false)
|
| 110 |
-
* @return
|
| 111 |
*/
|
| 112 |
function hmbkp_conform_dir( $dir, $rel = false ) {
|
| 113 |
|
|
@@ -183,7 +190,6 @@ function hmbkp_more_reccurences( $recc ) {
|
|
| 183 |
* Send a flie to the browser for download
|
| 184 |
*
|
| 185 |
* @param string $path
|
| 186 |
-
* @return void
|
| 187 |
*/
|
| 188 |
function hmbkp_send_file( $path ) {
|
| 189 |
|
|
@@ -320,34 +326,43 @@ function hmbkp_calculate() {
|
|
| 320 |
|
| 321 |
// Check cache
|
| 322 |
if ( $filesize = get_transient( 'hmbkp_estimated_filesize' ) )
|
| 323 |
-
return hmbkp_size_readable( $filesize );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
-
|
|
|
|
| 326 |
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
|
|
|
| 330 |
|
| 331 |
-
|
| 332 |
-
$sum_free += $r['Data_free'];
|
| 333 |
-
$sum_data += $r['Data_length'];
|
| 334 |
-
endforeach;
|
| 335 |
|
| 336 |
-
|
| 337 |
-
clearstatcache();
|
| 338 |
|
| 339 |
-
|
| 340 |
-
|
| 341 |
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
// Cache in a transient for a day
|
| 348 |
set_transient( 'hmbkp_estimated_filesize', $filesize, 86400 );
|
| 349 |
|
| 350 |
-
return hmbkp_size_readable( $filesize );
|
| 351 |
|
| 352 |
}
|
| 353 |
|
|
@@ -365,4 +380,23 @@ function hmbkp_shell_exec_available() {
|
|
| 365 |
|
| 366 |
return true;
|
| 367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
}
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Setup the default options on plugin activation
|
|
|
|
|
|
|
| 5 |
*/
|
| 6 |
function hmbkp_activate() {
|
| 7 |
+
|
| 8 |
+
hmbkp_setup_daily_schedule();
|
| 9 |
+
|
| 10 |
}
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Cleanup on plugin deactivation
|
| 14 |
*
|
| 15 |
* Removes options and clears all cron schedules
|
|
|
|
|
|
|
|
|
|
| 16 |
*/
|
| 17 |
function hmbkp_deactivate() {
|
| 18 |
|
| 19 |
+
// Options to delete
|
| 20 |
$options = array(
|
| 21 |
'hmbkp_zip_path',
|
| 22 |
'hmbkp_mysqldump_path',
|
| 30 |
foreach ( $options as $option )
|
| 31 |
delete_option( $option );
|
| 32 |
|
| 33 |
+
// Clear cron
|
|
|
|
| 34 |
wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' );
|
| 35 |
+
wp_clear_scheduled_hook( 'hmbkp_schedule_single_backup_hook' );
|
| 36 |
|
| 37 |
}
|
| 38 |
|
| 40 |
/**
|
| 41 |
* Handles anything that needs to be
|
| 42 |
* done when the plugin is updated
|
|
|
|
|
|
|
| 43 |
*/
|
| 44 |
function hmbkp_update() {
|
| 45 |
|
| 46 |
+
global $hmbkp_version;
|
| 47 |
+
|
| 48 |
+
// 1.0.x to 1.1
|
| 49 |
+
if ( !get_option( 'hmbkp_plugin_version' ) ) :
|
| 50 |
+
delete_transient( 'hmbkp_estimated_filesize' );
|
| 51 |
+
delete_option( 'hmbkp_max_backups' );
|
| 52 |
+
delete_option( 'hmbkp_backup_running' );
|
| 53 |
+
|
| 54 |
+
// Delete the logs directory
|
| 55 |
+
hmbkp_rmdirtree( hmbkp_path() . '/logs' );
|
| 56 |
+
|
| 57 |
+
endif;
|
| 58 |
|
| 59 |
// Update from backUpWordPress
|
| 60 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
| 95 |
|
| 96 |
endif;
|
| 97 |
|
| 98 |
+
// Update the stored version
|
| 99 |
+
update_option( 'hmbkp_plugin_version', $hmbkp_version );
|
| 100 |
+
|
| 101 |
}
|
| 102 |
|
| 103 |
/**
|
| 114 |
*
|
| 115 |
* @param string $dir
|
| 116 |
* @param bool $rel. (default: false)
|
| 117 |
+
* @return string $dir
|
| 118 |
*/
|
| 119 |
function hmbkp_conform_dir( $dir, $rel = false ) {
|
| 120 |
|
| 190 |
* Send a flie to the browser for download
|
| 191 |
*
|
| 192 |
* @param string $path
|
|
|
|
| 193 |
*/
|
| 194 |
function hmbkp_send_file( $path ) {
|
| 195 |
|
| 326 |
|
| 327 |
// Check cache
|
| 328 |
if ( $filesize = get_transient( 'hmbkp_estimated_filesize' ) )
|
| 329 |
+
return hmbkp_size_readable( $filesize, null, '%01u %s' );
|
| 330 |
+
|
| 331 |
+
$filesize = 0;
|
| 332 |
+
|
| 333 |
+
// Don't include database if files only
|
| 334 |
+
if ( ( defined( 'HMBKP_FILES_ONLY' ) && !HMBKP_FILES_ONLY ) || !defined( 'HMBKP_FILES_ONLY' ) ) :
|
| 335 |
+
|
| 336 |
+
global $wpdb;
|
| 337 |
|
| 338 |
+
$sql = 'SHOW TABLE STATUS FROM ' . DB_NAME;
|
| 339 |
+
$res = $wpdb->get_results( $sql, ARRAY_A );
|
| 340 |
|
| 341 |
+
foreach ( $res as $r ) :
|
| 342 |
+
$filesize += $r['Data_free'];
|
| 343 |
+
$filesize += $r['Data_length'];
|
| 344 |
+
endforeach;
|
| 345 |
|
| 346 |
+
endif;
|
|
|
|
|
|
|
|
|
|
| 347 |
|
| 348 |
+
if ( ( defined( 'HMBKP_DATABASE_ONLY' ) && !HMBKP_DATABASE_ONLY ) || !defined( 'HMBKP_DATABASE_ONLY' ) ) :
|
|
|
|
| 349 |
|
| 350 |
+
// Get rid of any cached filesizes
|
| 351 |
+
clearstatcache();
|
| 352 |
|
| 353 |
+
$files = hmbkp_ls( hmbkp_conform_dir( ABSPATH ) );
|
| 354 |
+
|
| 355 |
+
foreach ( $files as $f ) :
|
| 356 |
+
$str = hmbkp_conform_dir( $f, true );
|
| 357 |
+
$filesize += @filesize( $f );
|
| 358 |
+
endforeach;
|
| 359 |
+
|
| 360 |
+
endif;
|
| 361 |
|
| 362 |
// Cache in a transient for a day
|
| 363 |
set_transient( 'hmbkp_estimated_filesize', $filesize, 86400 );
|
| 364 |
|
| 365 |
+
return hmbkp_size_readable( $filesize, null, '%01u %s' );
|
| 366 |
|
| 367 |
}
|
| 368 |
|
| 380 |
|
| 381 |
return true;
|
| 382 |
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
/**
|
| 386 |
+
* Calculate the total filesize of all backups
|
| 387 |
+
*
|
| 388 |
+
* @return string
|
| 389 |
+
*/
|
| 390 |
+
function hmbkp_total_filesize() {
|
| 391 |
+
|
| 392 |
+
$files = hmbkp_get_backups();
|
| 393 |
+
$filesize = 0;
|
| 394 |
+
|
| 395 |
+
clearstatcache();
|
| 396 |
+
|
| 397 |
+
foreach ( $files as $f )
|
| 398 |
+
$filesize += @filesize( $f['file'] );
|
| 399 |
+
|
| 400 |
+
return hmbkp_size_readable( $filesize );
|
| 401 |
+
|
| 402 |
}
|
functions/interface.functions.php
CHANGED
|
@@ -4,13 +4,12 @@
|
|
| 4 |
*
|
| 5 |
* @param mixed $file
|
| 6 |
* @param mixed $alternate
|
| 7 |
-
* @return void
|
| 8 |
*/
|
| 9 |
function hmbkp_get_backup_row( $file ) {
|
| 10 |
|
| 11 |
$encode = base64_encode( $file['file'] ); ?>
|
| 12 |
|
| 13 |
-
<tr
|
| 14 |
|
| 15 |
<th scope="row">
|
| 16 |
<?php echo date( get_option('date_format'), filemtime( $file['file'] ) ) . ' ' . date( 'H:i', filemtime($file['file'] ) ); ?>
|
|
@@ -23,7 +22,7 @@ function hmbkp_get_backup_row( $file ) {
|
|
| 23 |
<td>
|
| 24 |
|
| 25 |
<a href="tools.php?page=<?php echo HMBKP_PLUGIN_SLUG; ?>&hmbkp_download=<?php echo $encode; ?>"><?php _e( 'Download', 'hmbkp' ); ?></a> |
|
| 26 |
-
<
|
| 27 |
|
| 28 |
</td>
|
| 29 |
|
| 4 |
*
|
| 5 |
* @param mixed $file
|
| 6 |
* @param mixed $alternate
|
|
|
|
| 7 |
*/
|
| 8 |
function hmbkp_get_backup_row( $file ) {
|
| 9 |
|
| 10 |
$encode = base64_encode( $file['file'] ); ?>
|
| 11 |
|
| 12 |
+
<tr class="hmbkp_manage_backups_row">
|
| 13 |
|
| 14 |
<th scope="row">
|
| 15 |
<?php echo date( get_option('date_format'), filemtime( $file['file'] ) ) . ' ' . date( 'H:i', filemtime($file['file'] ) ); ?>
|
| 22 |
<td>
|
| 23 |
|
| 24 |
<a href="tools.php?page=<?php echo HMBKP_PLUGIN_SLUG; ?>&hmbkp_download=<?php echo $encode; ?>"><?php _e( 'Download', 'hmbkp' ); ?></a> |
|
| 25 |
+
<a href="tools.php?page=<?php echo HMBKP_PLUGIN_SLUG; ?>&hmbkp_delete=<?php echo $encode ?>" class="delete"><?php _e( 'Delete', 'hmbkp' ); ?></a>
|
| 26 |
|
| 27 |
</td>
|
| 28 |
|
functions/settings.functions.php
CHANGED
|
@@ -1,29 +1,33 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
-
*
|
| 5 |
-
*
|
| 6 |
-
* @return void
|
| 7 |
*/
|
| 8 |
-
function
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
|
| 25 |
/**
|
| 26 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
*/
|
| 28 |
function hmbkp_path() {
|
| 29 |
|
|
@@ -52,4 +56,18 @@ function hmbkp_path() {
|
|
| 52 |
endif;
|
| 53 |
|
| 54 |
return $path;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
+
* Setup the daily backup schedule
|
|
|
|
|
|
|
| 5 |
*/
|
| 6 |
+
function hmbkp_setup_daily_schedule() {
|
| 7 |
|
| 8 |
+
// Clear any old schedules
|
| 9 |
+
wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' );
|
| 10 |
|
| 11 |
+
// Default to 11 in the evening
|
| 12 |
+
$time = '23:00';
|
| 13 |
|
| 14 |
+
// Allow it to be overridden
|
| 15 |
+
if ( defined( 'HMBKP_DAILY_SCHEDULE_TIME' ) && HMBKP_DAILY_SCHEDULE_TIME )
|
| 16 |
+
$time = HMBKP_DAILY_SCHEDULE_TIME;
|
| 17 |
+
|
| 18 |
+
if ( time() > strtotime( $time ) )
|
| 19 |
+
$time = 'tomorrow ' . $time;
|
| 20 |
+
|
| 21 |
+
wp_schedule_event( strtotime( $time ), 'hmbkp_daily', 'hmbkp_schedule_backup_hook' );
|
| 22 |
}
|
| 23 |
|
| 24 |
|
| 25 |
/**
|
| 26 |
+
* Get the path to the backups directory
|
| 27 |
+
*
|
| 28 |
+
* Will try to create it if it doesn't exist
|
| 29 |
+
* and will fallback to default if a custom dir
|
| 30 |
+
* isn't writable.
|
| 31 |
*/
|
| 32 |
function hmbkp_path() {
|
| 33 |
|
| 56 |
endif;
|
| 57 |
|
| 58 |
return $path;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* The maximum number of backups to keep
|
| 63 |
+
*
|
| 64 |
+
* @return int
|
| 65 |
+
*/
|
| 66 |
+
function hmbkp_max_backups() {
|
| 67 |
+
|
| 68 |
+
if ( defined( 'HMBKP_MAX_BACKUPS' ) && is_numeric( HMBKP_MAX_BACKUPS ) )
|
| 69 |
+
return (int) HMBKP_MAX_BACKUPS;
|
| 70 |
+
|
| 71 |
+
return 10;
|
| 72 |
+
|
| 73 |
}
|
plugin.php
CHANGED
|
@@ -5,11 +5,11 @@ Plugin Name: BackUpWordPress
|
|
| 5 |
Plugin URI: http://humanmade.co.uk/
|
| 6 |
Description: Simple automated backups of your WordPress powered website.
|
| 7 |
Author: Human Made Limited
|
| 8 |
-
Version: 1.
|
| 9 |
Author URI: http://humanmade.co.uk/
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
/* Copyright 2011
|
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify
|
| 15 |
it under the terms of the GNU General Public License as published by
|
|
@@ -26,28 +26,46 @@ Author URI: http://humanmade.co.uk/
|
|
| 26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 27 |
*/
|
| 28 |
|
| 29 |
-
// TODO use wp_filesystem
|
| 30 |
-
// TODO try to use zipArchive before pclzip
|
| 31 |
-
// TODO get rid of schedules
|
| 32 |
-
|
| 33 |
define( 'HMBKP_PLUGIN_SLUG', 'backupwordpress' );
|
| 34 |
define( 'HMBKP_PLUGIN_PATH', WP_PLUGIN_DIR . '/' . HMBKP_PLUGIN_SLUG );
|
| 35 |
define( 'HMBKP_PLUGIN_URL', WP_PLUGIN_URL . '/' . HMBKP_PLUGIN_SLUG );
|
| 36 |
|
| 37 |
// Load the admin actions file
|
| 38 |
function hmbkp_actions() {
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
// Fire the update action
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
require_once( HMBKP_PLUGIN_PATH . '/admin.actions.php' );
|
| 44 |
-
|
| 45 |
// Load admin css and js
|
| 46 |
if ( isset( $_GET['page'] ) && $_GET['page'] == HMBKP_PLUGIN_SLUG ) :
|
| 47 |
wp_enqueue_script( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.js' );
|
| 48 |
wp_enqueue_style( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.css' );
|
| 49 |
endif;
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
add_action( 'admin_init', 'hmbkp_actions' );
|
| 53 |
|
|
@@ -58,7 +76,6 @@ require_once( HMBKP_PLUGIN_PATH . '/admin.menus.php' );
|
|
| 58 |
require_once( HMBKP_PLUGIN_PATH . '/functions/core.functions.php' );
|
| 59 |
require_once( HMBKP_PLUGIN_PATH . '/functions/interface.functions.php' );
|
| 60 |
require_once( HMBKP_PLUGIN_PATH . '/functions/settings.functions.php' );
|
| 61 |
-
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.log.functions.php' );
|
| 62 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.functions.php' );
|
| 63 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.mysql.functions.php' );
|
| 64 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.files.functions.php' );
|
|
@@ -73,7 +90,8 @@ add_action( 'deactivate_' . HMBKP_PLUGIN_SLUG . '/plugin.php', 'hmbkp_deactivate
|
|
| 73 |
add_filter( 'cron_schedules', 'hmbkp_more_reccurences' );
|
| 74 |
|
| 75 |
// Cron hook for backups
|
| 76 |
-
add_action( 'hmbkp_schedule_backup_hook', '
|
|
|
|
| 77 |
|
| 78 |
// Make sure backups dir exists and is writable
|
| 79 |
if ( !is_dir( hmbkp_path() ) ) :
|
|
@@ -81,7 +99,7 @@ if ( !is_dir( hmbkp_path() ) ) :
|
|
| 81 |
function hmbkp_path_exists_warning() {
|
| 82 |
$php_user = exec( 'whoami' );
|
| 83 |
$php_group = reset( explode( ' ', exec( 'groups' ) ) );
|
| 84 |
-
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress
|
| 85 |
}
|
| 86 |
add_action( 'admin_notices', 'hmbkp_path_exists_warning' );
|
| 87 |
|
|
@@ -92,8 +110,14 @@ if ( is_dir( hmbkp_path() ) && !is_writable( hmbkp_path() ) ) :
|
|
| 92 |
function hmbkp_writable_path_warning() {
|
| 93 |
$php_user = exec( 'whoami' );
|
| 94 |
$php_group = reset( explode( ' ', exec( 'groups' ) ) );
|
| 95 |
-
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress
|
| 96 |
}
|
| 97 |
add_action( 'admin_notices', 'hmbkp_writable_path_warning' );
|
| 98 |
|
| 99 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
Plugin URI: http://humanmade.co.uk/
|
| 6 |
Description: Simple automated backups of your WordPress powered website.
|
| 7 |
Author: Human Made Limited
|
| 8 |
+
Version: 1.1
|
| 9 |
Author URI: http://humanmade.co.uk/
|
| 10 |
*/
|
| 11 |
|
| 12 |
+
/* Copyright 2011 Human Made Limited (email : hello@humanmade.co.uk)
|
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify
|
| 15 |
it under the terms of the GNU General Public License as published by
|
| 26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 27 |
*/
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
define( 'HMBKP_PLUGIN_SLUG', 'backupwordpress' );
|
| 30 |
define( 'HMBKP_PLUGIN_PATH', WP_PLUGIN_DIR . '/' . HMBKP_PLUGIN_SLUG );
|
| 31 |
define( 'HMBKP_PLUGIN_URL', WP_PLUGIN_URL . '/' . HMBKP_PLUGIN_SLUG );
|
| 32 |
|
| 33 |
// Load the admin actions file
|
| 34 |
function hmbkp_actions() {
|
| 35 |
+
|
| 36 |
+
global $hmbkp_version;
|
| 37 |
+
|
| 38 |
+
$plugin_data = get_plugin_data( __FILE__ );
|
| 39 |
+
$hmbkp_version = (float) $plugin_data['Version'];
|
| 40 |
+
|
| 41 |
// Fire the update action
|
| 42 |
+
if ( $hmbkp_version > (float) get_option( 'hmbkp_plugin_version' ) )
|
| 43 |
+
hmbkp_update();
|
| 44 |
+
|
| 45 |
require_once( HMBKP_PLUGIN_PATH . '/admin.actions.php' );
|
| 46 |
+
|
| 47 |
// Load admin css and js
|
| 48 |
if ( isset( $_GET['page'] ) && $_GET['page'] == HMBKP_PLUGIN_SLUG ) :
|
| 49 |
wp_enqueue_script( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.js' );
|
| 50 |
wp_enqueue_style( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.css' );
|
| 51 |
endif;
|
| 52 |
|
| 53 |
+
// Check whether we need to disable the cron
|
| 54 |
+
if ( defined( 'HMBKP_DISABLE_AUTOMATIC_BACKUP' ) && HMBKP_DISABLE_AUTOMATIC_BACKUP && wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) )
|
| 55 |
+
wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' );
|
| 56 |
+
|
| 57 |
+
// Or whether we need to re-enable it
|
| 58 |
+
elseif( ( defined( 'HMBKP_DISABLE_AUTOMATIC_BACKUP' ) && !HMBKP_DISABLE_AUTOMATIC_BACKUP || !defined( 'HMBKP_DISABLE_AUTOMATIC_BACKUP' ) ) && !wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) )
|
| 59 |
+
hmbkp_setup_daily_schedule();
|
| 60 |
+
|
| 61 |
+
// Allow the time of the daily backup to be changed
|
| 62 |
+
if ( defined( 'HMBKP_DAILY_SCHEDULE_TIME' ) && HMBKP_DAILY_SCHEDULE_TIME && wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) != strtotime( HMBKP_DAILY_SCHEDULE_TIME ) )
|
| 63 |
+
hmbkp_setup_daily_schedule();
|
| 64 |
+
|
| 65 |
+
// Reset if custom time is removed
|
| 66 |
+
elseif( ( ( defined( 'HMBKP_DAILY_SCHEDULE_TIME' ) && !HMBKP_DAILY_SCHEDULE_TIME ) || !defined( 'HMBKP_DAILY_SCHEDULE_TIME' ) ) && date( 'H:i', wp_next_scheduled( 'hmbkp_schedule_backup_hook' ) ) != '23:00' )
|
| 67 |
+
hmbkp_setup_daily_schedule();
|
| 68 |
+
|
| 69 |
}
|
| 70 |
add_action( 'admin_init', 'hmbkp_actions' );
|
| 71 |
|
| 76 |
require_once( HMBKP_PLUGIN_PATH . '/functions/core.functions.php' );
|
| 77 |
require_once( HMBKP_PLUGIN_PATH . '/functions/interface.functions.php' );
|
| 78 |
require_once( HMBKP_PLUGIN_PATH . '/functions/settings.functions.php' );
|
|
|
|
| 79 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.functions.php' );
|
| 80 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.mysql.functions.php' );
|
| 81 |
require_once( HMBKP_PLUGIN_PATH . '/functions/backup.files.functions.php' );
|
| 90 |
add_filter( 'cron_schedules', 'hmbkp_more_reccurences' );
|
| 91 |
|
| 92 |
// Cron hook for backups
|
| 93 |
+
add_action( 'hmbkp_schedule_backup_hook', 'hmbkp_do_backup' );
|
| 94 |
+
add_action( 'hmbkp_schedule_single_backup_hook', 'hmbkp_do_backup' );
|
| 95 |
|
| 96 |
// Make sure backups dir exists and is writable
|
| 97 |
if ( !is_dir( hmbkp_path() ) ) :
|
| 99 |
function hmbkp_path_exists_warning() {
|
| 100 |
$php_user = exec( 'whoami' );
|
| 101 |
$php_group = reset( explode( ' ', exec( 'groups' ) ) );
|
| 102 |
+
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress is almost ready.', 'hmbkp' ) . '</strong> ' . sprintf( __( 'The backups directory can\'t be created because your %s directory isn\'t writable, run %s or %s or create the folder yourself.', 'hmbkp' ), '<code>wp-content</code>', '<code>chown ' . $php_user . ':' . $php_group . ' ' . WP_CONTENT_DIR . '</code>', '<code>chmod 777 ' . WP_CONTENT_DIR . '</code>' ) . '</p></div>';
|
| 103 |
}
|
| 104 |
add_action( 'admin_notices', 'hmbkp_path_exists_warning' );
|
| 105 |
|
| 110 |
function hmbkp_writable_path_warning() {
|
| 111 |
$php_user = exec( 'whoami' );
|
| 112 |
$php_group = reset( explode( ' ', exec( 'groups' ) ) );
|
| 113 |
+
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress is almost ready.', 'hmbkp' ) . '</strong> ' . sprintf( __( 'Your backups directory isn\'t writable. run %s or %s or set the permissions yourself.', 'hmbkp' ), '<code>chown -R ' . $php_user . ':' . $php_group . ' ' . hmbkp_path() . '</code>', '<code>chmod -R 777 ' . hmbkp_path() . '</code>' ) . '</p></div>';
|
| 114 |
}
|
| 115 |
add_action( 'admin_notices', 'hmbkp_writable_path_warning' );
|
| 116 |
|
| 117 |
+
endif;
|
| 118 |
+
|
| 119 |
+
// Hook in on update core and do a backup
|
| 120 |
+
function hmbkp_backup_on_upgrade() {
|
| 121 |
+
|
| 122 |
+
}
|
| 123 |
+
add_filter( 'update_feedback', 'hmbkp_backup_on_upgrade' );
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: willmot, humanmade
|
|
| 3 |
Tags: back up, backup, backups
|
| 4 |
Requires at least: 3.0
|
| 5 |
Tested up to: 3.1
|
| 6 |
-
Stable tag: 1.
|
| 7 |
|
| 8 |
Simple automated backups of your WordPress powered website.
|
| 9 |
|
|
@@ -19,7 +19,7 @@ The plugin will try to use the `mysqldump` and `zip` commands via shell if they
|
|
| 19 |
|
| 20 |
== Frequently Asked Questions ==
|
| 21 |
|
| 22 |
-
Contact
|
| 23 |
|
| 24 |
== Screenshots ==
|
| 25 |
|
|
@@ -27,6 +27,25 @@ Contact hello@humanmade.co.uk for help and support
|
|
| 27 |
|
| 28 |
== Changelog ==
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
#### 1.0.4
|
| 31 |
|
| 32 |
Don't throw PHP Warnings when `shell_exec` is disabled
|
|
@@ -35,7 +54,7 @@ Don't throw PHP Warnings when `shell_exec` is disabled
|
|
| 35 |
|
| 36 |
Minor bug fix release.
|
| 37 |
|
| 38 |
-
* Suppress filesize() warnings when calculating backup size.
|
| 39 |
* Plugin should now work when symlinked.
|
| 40 |
* Remove all options on deactivate, you should now be able to deactivate then activate to fix issues with settings etc. becoming corrupt.
|
| 41 |
* Call setup_defaults for users who update from backupwordpress 0.4.5 so they get new settings.
|
| 3 |
Tags: back up, backup, backups
|
| 4 |
Requires at least: 3.0
|
| 5 |
Tested up to: 3.1
|
| 6 |
+
Stable tag: 1.1
|
| 7 |
|
| 8 |
Simple automated backups of your WordPress powered website.
|
| 9 |
|
| 19 |
|
| 20 |
== Frequently Asked Questions ==
|
| 21 |
|
| 22 |
+
Contact support@humanmade.co.uk for help/support.
|
| 23 |
|
| 24 |
== Screenshots ==
|
| 25 |
|
| 27 |
|
| 28 |
== Changelog ==
|
| 29 |
|
| 30 |
+
#### 1.1
|
| 31 |
+
|
| 32 |
+
* Remove the logging facility as it provided little benefit and complicated the code, your existing logs will be deleted on update.
|
| 33 |
+
* Expose the various `Constants` that can be defined to change advanced settings.
|
| 34 |
+
* Added the ability to disable the automatic backups completely `define( 'HMBKP_DISABLE_AUTOMATIC_BACKUP', true );`.
|
| 35 |
+
* Added the ability to switch to file only or database only backups `define( 'HMBKP_FILES_ONLY', true );` Or `define( 'HMBKP_DATABASE_ONLY', true );`.
|
| 36 |
+
* Added the ability to define how many old backups should be kept `define( 'HMBKP_MAX_BACKUPS', 20 );`
|
| 37 |
+
* Added the ability to define the time that the daily backup should run `define( 'HMBKP_DAILY_SCHEDULE_TIME', '16:30' );`
|
| 38 |
+
* Tweaks to the backups page layout.
|
| 39 |
+
* General bug fixes and improvements.
|
| 40 |
+
|
| 41 |
+
#### 1.0.5
|
| 42 |
+
|
| 43 |
+
* Don't ajax load estimated backup size if it's already been calculated.
|
| 44 |
+
* Fix time in backup complete log message.
|
| 45 |
+
* Don't mark backup as running until cron has been called, will fix issues with backup showing as running even if cron never fired.
|
| 46 |
+
* Show number of backups saved message.
|
| 47 |
+
* Add a link to the backups page to the plugin action links.
|
| 48 |
+
|
| 49 |
#### 1.0.4
|
| 50 |
|
| 51 |
Don't throw PHP Warnings when `shell_exec` is disabled
|
| 54 |
|
| 55 |
Minor bug fix release.
|
| 56 |
|
| 57 |
+
* Suppress `filesize()` warnings when calculating backup size.
|
| 58 |
* Plugin should now work when symlinked.
|
| 59 |
* Remove all options on deactivate, you should now be able to deactivate then activate to fix issues with settings etc. becoming corrupt.
|
| 60 |
* Call setup_defaults for users who update from backupwordpress 0.4.5 so they get new settings.
|
