Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Sep 24, 2024
2 parents bacb0ed + 096bf3f commit 51f706f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ public static function backupContainer($container, $destination) {
$tarVerifyOptions = array_merge($tarExcludes, ['--diff']); // Add excludes to the beginning - https://unix.stackexchange.com/a/33334
$tarOptions = array_merge($tarExcludes, ['-c', '-P']); // Add excludes to the beginning - https://unix.stackexchange.com/a/33334

if ($abSettings->ignoreExclusionCase == 'yes') {
$tarOptions[] = '--ignore-case';
$tarVerifyOptions[] = '--ignore-case';
}

switch ($abSettings->compression) {
case 'yes':
$tarOptions[] = '-z'; // GZip
Expand All @@ -414,22 +419,35 @@ public static function backupContainer($container, $destination) {
self::backupLog("Generated tar command: " . $finalTarOptions, self::LOGLEVEL_DEBUG);
self::backupLog("Backing up " . $container['Name'] . '...');

$tarBackupTimer = time();

$output = $resultcode = null;
exec("tar " . $finalTarOptions . " 2>&1 " . ABSettings::$externalCmdPidCapture, $output, $resultcode);
self::backupLog("Tar out: " . implode('; ', $output), self::LOGLEVEL_DEBUG);

if ($resultcode > 0) {
self::backupLog("tar creation failed! Tar said: " . implode('; ', $output), $containerSettings['ignoreBackupErrors'] == 'yes' ? self::LOGLEVEL_INFO : self::LOGLEVEL_ERR);

/**
* Special debug: The creation was ok but verification failed: Something is accessing docker files! List docker info for this container
*/
foreach ($volumes as $volume) {
$output = null;
exec("lsof -nl +D " . escapeshellarg($volume), $output);
self::backupLog("lsof($volume)" . PHP_EOL . print_r($output, true), self::LOGLEVEL_DEBUG);
}

return $containerSettings['ignoreBackupErrors'] == 'yes';
}

self::backupLog("Backup created without issues");
self::backupLog("Backup created without issues (took " . gmdate("H:i:s", time() - $tarBackupTimer) . " (hours:mins:secs))");

if (self::abortRequested()) {
return true;
}

if ($containerSettings['verifyBackup'] == 'yes') {
$tarVerifyTimer = time();
self::backupLog("Verifying backup...");
self::backupLog("Final verify command: " . $finalTarVerifyOptions, self::LOGLEVEL_DEBUG);

Expand All @@ -455,6 +473,8 @@ public static function backupContainer($container, $destination) {
}
}
return $containerSettings['ignoreBackupErrors'] == 'yes';
} else {
self::backupLog("Verification ended without issues (took " . gmdate("H:i:s", time() - $tarVerifyTimer) . " (hours:mins:secs))");
}
} else {
self::backupLog("Skipping verification for this container because its not wanted!", self::LOGLEVEL_WARN);
Expand Down
1 change: 1 addition & 0 deletions src/include/ABSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ABSettings {
public string $backupVMMeta = 'yes';
public string $successLogWanted = 'no';
public string $updateLogWanted = 'no';
public string $ignoreExclusionCase = 'no';

public function __construct() {

Expand Down
26 changes: 24 additions & 2 deletions src/pages/content/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,18 @@
</select>
</dd>

<dt>
<div style="display: table; line-height: 1em;"><b>Enable <code>--ignore-case</code> for
tar?</b><br/><small>This ignores case sensitivity for exclusions.</small>
</div>
</dt>
<dd><select id='ignoreExclusionCase' name="ignoreExclusionCase"
data-setting="<?= $abSettings->ignoreExclusionCase ?>">
<option value='yes'>Yes</option>
<option value='no'>No</option>
</select>
</dd>

</dl>
</div>

Expand Down Expand Up @@ -593,10 +605,20 @@ class="fa fa-clock-o title"></i>Notifications and scheduling</span>
$containerExcludes = implode("\r\n", $containerSetting['exclude']);

echo <<<HTML
<style>
.containerSettingsDt {
overflow: hidden;
white-space: nowrap
}
.containerSettingsDt:after {
opacity: 0.1;
content: " _____________________________________________________________________________________________________________________________________________________________________";
}
</style>
<div style="display: none" id="actualContainerSettings_{$container['Name']}">$realContainerSetting</div>
<dl>
<dt><img alt="pic" src='$image' height='16' /> <i title='{$container['Image']}' class='fa fa-info-circle'></i> <abbr title='Click for advanced settings'>{$container['Name']}$plexContainerNameSuffix</abbr> <span id="containerMultiMappingIssue_{$container['Name']}" style="display: none; color: darkorange;">WARN: Multi mapping detected!</span></dt>
<dd><label for="{$container['Name']}_skip">Skip?</label>
<dt class="containerSettingsDt"><img alt="pic" src='$image' height='16' /> <i title='{$container['Image']}' class='fa fa-info-circle'></i> <abbr title='Click for advanced settings'>{$container['Name']}$plexContainerNameSuffix</abbr> <span id="containerMultiMappingIssue_{$container['Name']}" style="display: none; color: darkorange;">WARN: Multi mapping detected!</span></dt>
<dd><label for="{$container['Name']}_skip">&nbsp;&nbsp;Skip?</label>
<select name="containerSettings[{$container['Name']}][skip]" id="{$container['Name']}_skip" data-setting="{$containerSetting['skip']}">
<option value="no">No</option>
<option value="yes">Yes</option>
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@

$tarOptions = array_merge($tarExcludes, ['-c', '-P']); // Add excludes to the beginning - https://unix.stackexchange.com/a/33334

if ($abSettings->ignoreExclusionCase == 'yes') {
$tarOptions[] = '--ignore-case';
}

$destination = $abDestination . '/extra_files.tar';

switch ($abSettings->compression) {
Expand Down

0 comments on commit 51f706f

Please sign in to comment.