Skip to content

Commit

Permalink
###2023.01.11
Browse files Browse the repository at this point in the history
- 🚀 Happy new year!
- Added an option, to disable backup error detection.
  • Loading branch information
Commifreak committed Jan 11, 2023
1 parent 1f8d525 commit 6ba7534
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
8 changes: 6 additions & 2 deletions ca.backup2.plg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "ca.backup2">
<!ENTITY author "Robin Kluth">
<!ENTITY version "2022.12.27">
<!ENTITY md5 "29229aedd91d96e8531e6f50b6f176c4">
<!ENTITY version "2023.01.11">
<!ENTITY md5 "380090359a8ced1f18b930c945a91a92">
<!ENTITY launch "Settings/BackupMainV2">
<!ENTITY plugdir "/usr/local/emhttp/plugins/&name;">
<!ENTITY github "Commifreak/ca.backup2">
Expand All @@ -14,6 +14,10 @@

<CHANGES>
<![CDATA[
###2023.01.11
- 🚀 Happy new year!
- Added an option, to disable backup error detection.
###2022.12.27
- Fixed restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ if ( ! isset($backupOptions['compression']) ) { $backupOptions['compression'] =
if ( ! isset($backupOptions['verify']) ) { $backupOptions['verify'] = "yes"; }
if ( ! isset($backupOptions['hideDockerWarning']) ) { $backupOptions['hideDockerWarning'] = "no"; }
if ( ! isset($backupOptions['separateArchives']) ) { $backupOptions['separateArchives'] = "no"; }
if ( ! isset($backupOptions['ignoreBackupErrors']) ) { $backupOptions['ignoreBackupErrors'] = "no"; }

# fix destinationShare for compatibility with initial release

Expand Down Expand Up @@ -272,6 +273,7 @@ $(function() {
$("#verify").val("<?=$backupOptions['verify']?>");
$("#hideDockerWarning").val("<?=$backupOptions['hideDockerWarning']?>");
$("#separateArchives").val("<?=$backupOptions['separateArchives']?>");
$("#ignoreBackupErrors").val("<?=$backupOptions['ignoreBackupErrors']?>");

if ( "<?=$caUpdateInstalled?>" != "true" ) {
$("#updateApps").prop("disabled",true);
Expand Down Expand Up @@ -569,13 +571,21 @@ function toggleDockerStop(el) {
</td>
</tr>
<tr>
<td><b>Verify Backups?</b></td>
<td><b>Verify Backups?</b><br />This can lead to broken backups - Only enable if you know what you do!</td>
<td><select class='setting' id='verify' onchange='validateOptions();'>
<option value='no'>No</option>
<option value='yes'>Yes</option>
</select>
</td>
</tr>
<tr>
<td><b>Ignore errors during backup?</b><br />This can lead to broken backups - Only enable if you know what you do!</td>
<td><select class='setting' id='ignoreBackupErrors' onchange='validateOptions();'>
<option value='no'>No</option>
<option value='yes'>Yes</option>
</select>
</td>
</tr>
<tr>
<td><b>Create separate archives (one per folder)?</b></td>
<td><select class='setting' id='separateArchives' onchange='validateOptions();'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ function backupLog($msg, $newLine = true, $skipDate = false)
if (!$backupOptions['dockerStopDelay']) {
$backupOptions['dockerStopDelay'] = 10;
}

if(empty($backupOptions['ignoreBackupErrors'])) {
$backupOptions['ignoreBackupErrors'] = 'no';
}

$backupOptions["rsyncOption"] = " -avXHq --delete ";

$newFolderDated = exec("date +%F@%H.%M");
Expand Down Expand Up @@ -219,6 +224,7 @@ function backupLog($msg, $newLine = true, $skipDate = false)
if (is_dir($source)) {

// Prepare destination.
// TODO: Checks those things at the top!
exec("mkdir -p " . escapeshellarg($destination));
exec("chmod 0777 " . escapeshellarg($destination));

Expand Down Expand Up @@ -282,26 +288,31 @@ function backupLog($msg, $newLine = true, $skipDate = false)

if ($returnValue > 0) {
backupLog("tar creation/extraction failed!");
$errorOccured = true;
} else {
if (!$restore)
exec("chmod 0777 " . escapeshellarg("{$destination}/CA_backup$folderName$fileExt"));
if($backupOptions['ignoreBackupErrors'] == 'no') {
$errorOccured = true;
} else {
backupLog("... but being ignored because the user said so!");
continue;
}
}

logger("$restoreMsg Complete");
if ($backupOptions['verify'] == "yes" && !$restore) {
$command = "cd " . escapeshellarg("$source") . " && /usr/bin/tar --diff -C '$source' -af " . escapeshellarg("$destination/CA_backup" . (empty($folderName) ? '' : '_') . "$folderName$fileExt") . " >> {$communityPaths['backupLog']} 2>&1 & echo $! > {$communityPaths['verifyProgress']} && wait $!";
backupLog("Verifying Backup $folderName");
logger("Using command: $command");
exec($command, $out, $returnValue);
if(!file_exists($communityPaths['verifyProgress'])) {
backupLog("User aborted backup!");
break;
}
unlink($communityPaths['verifyProgress']);
if ($returnValue > 0) { // Todo: Being overwritten!!
backupLog("tar verify failed!");
$errorOccured = true;
}
if (!$restore)
exec("chmod 0777 " . escapeshellarg("{$destination}/CA_backup$folderName$fileExt"));

logger("$restoreMsg Complete");
if ($backupOptions['verify'] == "yes" && !$restore) {
$command = "cd " . escapeshellarg("$source") . " && /usr/bin/tar --diff -C '$source' -af " . escapeshellarg("$destination/CA_backup" . (empty($folderName) ? '' : '_') . "$folderName$fileExt") . " >> {$communityPaths['backupLog']} 2>&1 & echo $! > {$communityPaths['verifyProgress']} && wait $!";
backupLog("Verifying Backup $folderName");
logger("Using command: $command");
exec($command, $out, $returnValue);
if(!file_exists($communityPaths['verifyProgress'])) {
backupLog("User aborted backup!");
break;
}
unlink($communityPaths['verifyProgress']);
if ($returnValue > 0) { // Todo: Being overwritten!!
backupLog("tar verify failed!");
$errorOccured = true;
}
}
}
Expand Down

0 comments on commit 6ba7534

Please sign in to comment.