Skip to content

Commit 50d8423

Browse files
committed
Fix restore
1 parent 48fa524 commit 50d8423

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

ca.backup2.plg

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<!DOCTYPE PLUGIN [
33
<!ENTITY name "ca.backup2">
44
<!ENTITY author "Robin Kluth">
5-
<!ENTITY version "2022.12.22">
6-
<!ENTITY md5 "cb3956c01906cb3ec0e979e6675b9657">
5+
<!ENTITY version "2022.12.27">
6+
<!ENTITY md5 "29229aedd91d96e8531e6f50b6f176c4">
77
<!ENTITY launch "Settings/BackupMainV2">
88
<!ENTITY plugdir "/usr/local/emhttp/plugins/&name;">
99
<!ENTITY github "Commifreak/ca.backup2">
@@ -13,6 +13,10 @@
1313
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" icon="shield">
1414

1515
<CHANGES>
16+
<![CDATA[
17+
##2022.12.27
18+
- Fixed restore
19+
1620
##2022.12.22
1721
- Added some debug infos for the "Already started" docker issue
1822
- Fixes "Abort" function
@@ -118,6 +122,7 @@ version.
118122
119123
###2017.11.05
120124
- Initial Release
125+
]]>
121126
</CHANGES>
122127

123128
<!-- The 'pre-install' script. -->

source/ca.backup2/usr/local/emhttp/plugins/ca.backup2/scripts/backup.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ function backupLog($msg, $newLine = true, $skipDate = false)
209209

210210
$logLine = $restore ? "Restoring" : "Backing Up";
211211
$fileExt = ($backupOptions['compression']) == "yes" ? ".tar.gz" : ".tar";
212-
backupLog("$logLine appData from $source to $destination");
212+
if($restore) {
213+
backupLog("$logLine appData from $restoreSource to $restoreDestination");
214+
} else {
215+
backupLog("$logLine appData from $source to $destination");
216+
}
213217

214218
if (!$restore) {
215219
if (is_dir($source)) {
@@ -249,7 +253,7 @@ function backupLog($msg, $newLine = true, $skipDate = false)
249253
exec("mkdir -p " . escapeshellarg($restoreDestination));
250254

251255
foreach ($restoreItems as $item) {
252-
if (in_array($item, ['.', '..'])) {
256+
if (in_array($item, ($restore ? ['.', '..', 'backup.log'] : ['.', '..']))) {
253257
// Ignore . and ..
254258
continue;
255259
}
@@ -271,13 +275,13 @@ function backupLog($msg, $newLine = true, $skipDate = false)
271275

272276
exec($command, $out, $returnValue);
273277

274-
if(!file_exists($communityPaths['backupProgress'])) {
275-
backupLog("User aborted backup!");
278+
if(!file_exists(($restore ? $communityPaths['restoreProgress'] : $communityPaths['backupProgress']))) {
279+
backupLog("User aborted backup/restore!");
276280
break;
277281
}
278282

279283
if ($returnValue > 0) {
280-
backupLog("tar creation failed!");
284+
backupLog("tar creation/extraction failed!");
281285
$errorOccured = true;
282286
} else {
283287
if (!$restore)

0 commit comments

Comments
 (0)