Last active
September 15, 2020 18:15
-
-
Save glaubersilva/7d03f9a275f682041aae5528725ce06b to your computer and use it in GitHub Desktop.
Snapshot V.4 - Common Fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [GS] Delete wp_snapshot_backup_schedule option | |
* Plugin URI: https://glaubersilva.me/ | |
* Description: Sometimes the schedule option get corrupted in the database and when you try to exchange the date-time in Snapshot you get the message: "Request for a backup schedule was not successful." - This plugin can help you to solve this problem. | |
* Author: Glauber Silva | |
* Author URI: https://glaubersilva.me/ | |
* License: GPLv2 or later | |
* | |
* @package GS_Delete_wp_snapshot_backup_schedule_Option | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
/** | |
* Add this file in you /wp-content/mu-plugins folder | |
* To delete the option, access: YOUR-DOMAIN.COM/?delete=wp_snapshot_backup_schedule | |
* After that, delete this file! | |
*/ | |
function gs_delete_snapshot_schedule_option(){ | |
if ( isset( $_REQUEST['delete'] ) && 'wp_snapshot_backup_schedule' === $_REQUEST['delete'] ) { | |
$response = delete_option( $_REQUEST['delete'] ); | |
if ( $response ){ | |
echo 'The <b>wp_snapshot_backup_schedule</b> option was successfully deleted.<br><br>'; | |
echo '<b>ATTENTION:</b> remember to remove this plugin now that the option already is deleted! ;)<br><br>'; | |
exit; | |
} | |
} | |
} | |
add_action( 'init', 'gs_delete_snapshot_schedule_option' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [GS] Snapshot Skip Views | |
* Plugin URI: https://glaubersilva.me/ | |
* Description: Snapshot can't backup views, just tables. Views generate errors that stop the backup like this: "Unreachable table PREFIX_affiliate_wp_campaigns". So this snippet solves this problem. | |
* Author: Glauber Silva | |
* Author URI: https://glaubersilva.me/ | |
* License: GPLv2 or later | |
* | |
* @package GS_Snapshot_Skip_Views | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
function gs_skip_views_on_snapshot_backup( $tables ) { | |
/** | |
* Check all views in your database (via phpMyAdmin or other) and put them here - separate by a comma and without the database prefix. | |
*/ | |
$views = array( | |
'affiliate_wp_campaigns', | |
); | |
foreach( $tables as $id => $table ){ | |
foreach( $views as $view ){ | |
if( false !== strpos( $table, $view ) ){ | |
unset( $tables[ $id ] ); | |
} | |
} | |
} | |
return $tables; | |
} | |
add_filter( 'snapshot_tables_for_backup', 'gs_skip_views_on_snapshot_backup' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ALL CONTENT OF THE ORIGINAL FILE GOES HERE... | |
// Displays More Details in the Logs | |
define('SNAPSHOT4_FILELIST_LOG_VERBOSE', true); // Comment or remove this after the debug session | |
define('SNAPSHOT4_FILE_ZIPSTREAM_LOG_VERBOSE', true); // Comment or remove this after the debug session | |
// Utils when occurring the error: snapshot_failed_FetchFileslist | |
define( 'SNAPSHOT4_CHUNKED_ZIPSTREAMING_LARGE', true ); | |
// Utils when occurring the error: snapshot_failed_SiteNotRespondedError | |
define( 'WP_MEMORY_LIMIT', '1024M' ); // PHP memory limit - memory_limit | |
set_time_limit(1000); // PHP time limit - max_execution_time | |
/* That's all, stop editing! Happy blogging. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment