WordPress Backup and Migrate Plugin – Backup Guard - Version 1.2.9

Version Description

  • The bug related to inprogress backup and restore was fixed.
Download this release

Release Info

Developer BackupGuard
Plugin Icon 128x128 WordPress Backup and Migrate Plugin – Backup Guard
Version 1.2.9
Comparing to
See all releases

Code changes from version 1.2.8 to 1.2.9

README.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://backup-guard.com/products/backup-wordpress
6
  Tags: backup, wordpress backup plugin, backup plugin, database backup, migrate, back up
7
  Requires at least: 3.8
8
  Tested up to: 5.4
9
- Stable tag: 1.2.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -157,6 +157,9 @@ When you are facing an issue of any kind with any of our products, the first thi
157
  6. Site backup customization
158
 
159
  == Changelog ==
 
 
 
160
  = 1.2.8 =
161
  * Bug fixed related to restore.
162
  * Admin side design improvements
6
  Tags: backup, wordpress backup plugin, backup plugin, database backup, migrate, back up
7
  Requires at least: 3.8
8
  Tested up to: 5.4
9
+ Stable tag: 1.2.9
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
157
  6. Site backup customization
158
 
159
  == Changelog ==
160
+ = 1.2.9 =
161
+ * The bug related to inprogress backup and restore was fixed.
162
+
163
  = 1.2.8 =
164
  * Bug fixed related to restore.
165
  * Admin side design improvements
backup.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Backup
5
  * Plugin URI: https://backup-guard.com/products/backup-wordpress
6
  * Description: Backup Guard is the most complete site backup and restore plugin. We offer the easiest way to backup, restore or migrate your site. You can backup your files, database or both.
7
- * Version: 1.2.8
8
  * Author: BackupGuard
9
  * Author URI: https://backup-guard.com/products/backup-wordpress
10
  * License: GPL-2.0+
@@ -16,7 +16,7 @@ if (function_exists('activate_backup_guard')) {
16
  }
17
 
18
  if (!defined('SG_BACKUP_GUARD_VERSION')) {
19
- define('SG_BACKUP_GUARD_VERSION', '1.2.8');
20
  }
21
 
22
  if (!defined('SG_BACKUP_GUARD_MAIN_FILE')) {
4
  * Plugin Name: Backup
5
  * Plugin URI: https://backup-guard.com/products/backup-wordpress
6
  * Description: Backup Guard is the most complete site backup and restore plugin. We offer the easiest way to backup, restore or migrate your site. You can backup your files, database or both.
7
+ * Version: 1.2.9
8
  * Author: BackupGuard
9
  * Author URI: https://backup-guard.com/products/backup-wordpress
10
  * License: GPL-2.0+
16
  }
17
 
18
  if (!defined('SG_BACKUP_GUARD_VERSION')) {
19
+ define('SG_BACKUP_GUARD_VERSION', '1.2.9');
20
  }
21
 
22
  if (!defined('SG_BACKUP_GUARD_MAIN_FILE')) {
com/core/backup/SGBackup.php CHANGED
@@ -1120,6 +1120,32 @@ class SGBackup implements SGIBackupDelegate
1120
  }
1121
  return (int)$res[0]['status'];
1122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1123
 
1124
  public static function getRunningActions()
1125
  {
1120
  }
1121
  return (int)$res[0]['status'];
1122
  }
1123
+
1124
+ public static function deleteActionById($actionId)
1125
+ {
1126
+ $sgdb = SGDatabase::getInstance();
1127
+ $res = $sgdb->query('DELETE FROM '.SG_ACTION_TABLE_NAME.' WHERE id=%d', array($actionId));
1128
+
1129
+ return $res;
1130
+ }
1131
+
1132
+ public static function cleanRunningActions($runningActions)
1133
+ {
1134
+ if (empty($runningActions)) {
1135
+ return false;
1136
+ }
1137
+ foreach ($runningActions as $action) {
1138
+ if (empty($action)) {
1139
+ continue;
1140
+ }
1141
+ if ($action['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES) {
1142
+ $id = $action['id'];
1143
+ SGBackup::deleteActionById($id);
1144
+ }
1145
+ }
1146
+
1147
+ return true;
1148
+ }
1149
 
1150
  public static function getRunningActions()
1151
  {
com/lib/SGArchiveToZip.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SGArchiveToZip
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->backupFiles = new SGBackupFiles();
8
+ }
9
+
10
+ private $filePath;
11
+ private $fileName;
12
+
13
+ public function setFilePath($filePath)
14
+ {
15
+ $this->filePath = $filePath;
16
+ }
17
+
18
+ public function getFilePath()
19
+ {
20
+ return $this->filePath;
21
+ }
22
+
23
+ public function setFileName($fileName)
24
+ {
25
+ $this->fileName = $fileName;
26
+ }
27
+
28
+ public function getFileName()
29
+ {
30
+ return $this->fileName;
31
+ }
32
+
33
+ public function convert()
34
+ {
35
+ $this->extract();
36
+ }
37
+
38
+ private function extract()
39
+ {
40
+ $backupName = $this->getFileName();
41
+ $backupName = backupGuardRemoveSlashes($backupName);
42
+ $backupPath = SG_BACKUP_DIRECTORY.$backupName;
43
+ $filePath = $backupPath.'/'.$backupName.'.sgbp';
44
+
45
+ $files = new SGBackup();
46
+ $files->extractForZip($filePath, $backupPath, $backupName);
47
+ //$files->extractBackupByPath($backupPath.'/'.$backupName.'.sgbp', $backupName);
48
+ }
49
+ }
com/lib/test.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Array
2
+ (
3
+ [siteUrl] => http://localhost:8888/wordpress
4
+ [home] => http://localhost:8888/wordpress
5
+ [dbPrefix] => wp_
6
+ [tables] => ["wp_options","wp_commentmeta","wp_comments","wp_custom","wp_links","wp_postmeta","wp_posts","wp_term_relationships","wp_term_taxonomy","wp_termmeta","wp_terms","wp_usermeta","wp_users","wp_wfblockediplog"]
7
+ [method] => 2
8
+ [multisitePath] =>
9
+ [multisiteDomain] =>
10
+ [selectivRestoreable] => 1
11
+ [phpVersion] => 7.0.31
12
+ [version] => 5
13
+ )
14
+ Array
15
+ (
16
+ [siteUrl] => http://localhost:8888/wordpress
17
+ [home] => http://localhost:8888/wordpress
18
+ [dbPrefix] => wp_
19
+ [tables] => ["wp_options","wp_commentmeta","wp_comments","wp_custom","wp_links","wp_postmeta","wp_posts","wp_term_relationships","wp_term_taxonomy","wp_termmeta","wp_terms","wp_usermeta","wp_users","wp_wfblockediplog"]
20
+ [method] => 2
21
+ [multisitePath] =>
22
+ [multisiteDomain] =>
23
+ [selectivRestoreable] => 1
24
+ [phpVersion] => 7.0.31
25
+ [version] => 5
26
+ )
public/ajax/checkBackupCreation.php CHANGED
@@ -1,17 +1,31 @@
1
  <?php
2
- require_once(dirname(__FILE__).'/../boot.php');
3
- require_once(SG_BACKUP_PATH.'SGBackup.php');
4
- if(backupGuardIsAjax())
5
- {
6
- while (true)
7
- {
8
- $created = SGConfig::get('SG_RUNNING_ACTION', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- if ($created)
11
- {
12
- die('1');
13
- }
14
- }
15
-
16
- die('2');
17
- }
1
  <?php
2
+ require_once(dirname(__FILE__).'/../boot.php');
3
+ require_once(SG_BACKUP_PATH.'SGBackup.php');
4
+ if(backupGuardIsAjax()) {
5
+ $runningActions = array();
6
+
7
+ $timeout = 10; //in sec
8
+ while ($timeout != 0) {
9
+ sleep(1);
10
+ $timeout--;
11
+
12
+ $created = SGConfig::get('SG_RUNNING_ACTION', true);
13
+ if ($created) {
14
+ die((1));
15
+ }
16
+ $runningActions = SGBackup::getRunningActions();
17
+
18
+ if (empty($runningActions)) {
19
+ break;
20
+ }
21
+ }
22
+
23
+ if (!empty($runningActions)) {
24
+ SGBackup::cleanRunningActions($runningActions);
25
+ die(json_encode(array(
26
+ 'status' => 'cleaned'
27
+ )));
28
+ }
29
 
30
+ die('2');
31
+ }
 
 
 
 
 
 
public/ajax/checkRestoreCreation.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  require_once(dirname(__FILE__).'/../boot.php');
4
  require_once(SG_BACKUP_PATH.'SGBackup.php');
 
5
 
6
  if (backupGuardIsAjax()) {
7
  $timeout = 10; //in sec
@@ -12,7 +13,8 @@ if (backupGuardIsAjax()) {
12
 
13
  if ($created) {
14
  $runningActions = SGBackup::getRunningActions();
15
- if ($runningActions) {
 
16
  $actionId = $runningActions[0]['id'];
17
  die(json_encode(array(
18
  'status' => 0,
@@ -21,6 +23,18 @@ if (backupGuardIsAjax()) {
21
  )));
22
  }
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  die('{"status":1}');
2
 
3
  require_once(dirname(__FILE__).'/../boot.php');
4
  require_once(SG_BACKUP_PATH.'SGBackup.php');
5
+ $runningActions = array();
6
 
7
  if (backupGuardIsAjax()) {
8
  $timeout = 10; //in sec
13
 
14
  if ($created) {
15
  $runningActions = SGBackup::getRunningActions();
16
+ // when there are multiple uncompleted actions
17
+ if ($runningActions && count($runningActions) == 1 && $runningActions[0]['progress'] == 0) {
18
  $actionId = $runningActions[0]['id'];
19
  die(json_encode(array(
20
  'status' => 0,
23
  )));
24
  }
25
  }
26
+
27
+ $runningActions = SGBackup::getRunningActions();
28
+
29
+ if (empty($runningActions)) {
30
+ break;
31
+ }
32
+ }
33
+ if (!empty($runningActions)) {
34
+ SGBackup::cleanRunningActions($runningActions);
35
+ die(json_encode(array(
36
+ 'status' => 'cleaned'
37
+ )));
38
  }
39
 
40
  die('{"status":1}');
public/js/sgbackup.js CHANGED
@@ -509,21 +509,32 @@ sgBackup.fileUploadProgress = function(e){
509
  }
510
 
511
  sgBackup.checkBackupCreation = function(){
 
512
  var sgBackupCreationHandler = new sgRequestHandler('checkBackupCreation', {token: BG_BACKUP_STRINGS.nonce});
513
  sgBackupCreationHandler.dataType = 'html';
514
- sgBackupCreationHandler.callback = function(response){
515
- jQuery('#sg-modal').modal('hide');
516
- location.reload();
 
 
 
 
 
 
517
  };
518
  sgBackupCreationHandler.run();
519
  };
520
 
521
  sgBackup.checkRestoreCreation = function(){
 
522
  var sgRestoreCreationHandler = new sgRequestHandler('checkRestoreCreation', {token: BG_BACKUP_STRINGS.nonce});
523
  sgRestoreCreationHandler.callback = function(response){
524
  if (response.status==0 && response.external_enabled==1) {
525
  location.href = response.external_url;
526
  }
 
 
 
527
  else {
528
  location.reload();
529
  }
509
  }
510
 
511
  sgBackup.checkBackupCreation = function(){
512
+ jQuery('#manualBackup .btn-success').attr('disabled', true);
513
  var sgBackupCreationHandler = new sgRequestHandler('checkBackupCreation', {token: BG_BACKUP_STRINGS.nonce});
514
  sgBackupCreationHandler.dataType = 'html';
515
+ sgBackupCreationHandler.callback = function(response) {
516
+ var result = jQuery.parseJSON(response);
517
+ if (result && result.status == 'cleaned') {
518
+ sgBackup.manualBackup();
519
+ }
520
+ else {
521
+ jQuery('#sg-modal').modal('hide');
522
+ location.reload();
523
+ }
524
  };
525
  sgBackupCreationHandler.run();
526
  };
527
 
528
  sgBackup.checkRestoreCreation = function(){
529
+ jQuery('#manualBackup .btn-success').attr('disabled', true);
530
  var sgRestoreCreationHandler = new sgRequestHandler('checkRestoreCreation', {token: BG_BACKUP_STRINGS.nonce});
531
  sgRestoreCreationHandler.callback = function(response){
532
  if (response.status==0 && response.external_enabled==1) {
533
  location.href = response.external_url;
534
  }
535
+ else if (response.status == 'cleaned') {
536
+ jQuery('#manualBackup .btn-success').click();
537
+ }
538
  else {
539
  location.reload();
540
  }