Skip to content

Commit 8f1fcde

Browse files
committed
fix selecting a backup container
Signed-off-by: szaimen <[email protected]>
1 parent 8a6de8f commit 8f1fcde

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

Containers/borgbackup/backupscript.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ get_expiration_time() {
1515
DURATION_READABLE=$(printf "%02d hours %02d minutes %02d seconds" $DURATION_HOUR $DURATION_MIN $DURATION_SEC)
1616
}
1717

18-
# Export defaults
19-
export BORG_PASSPHRASE="$BORG_PASSWORD"
20-
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
21-
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
22-
2318
# Test if all volumes aren't empty
2419
VOLUME_DIRS="$(find /nextcloud_aio_volumes -mindepth 1 -maxdepth 1 -type d)"
2520
mapfile -t VOLUME_DIRS <<< "$VOLUME_DIRS"
@@ -168,7 +163,7 @@ if [ "$BORG_MODE" = restore ]; then
168163

169164
# Perform the restore
170165
if [ -n "$SELECTED_RESTORE_TIME" ]; then
171-
SELECTED_ARCHIVE"$(borg list "$BORG_BACKUP_DIRECTORY" | grep "nextcloud-aio" | grep "$SELECTED_RESTORE_TIME" | awk -F " " '{print $1}' | head -1)"
166+
SELECTED_ARCHIVE="$(borg list "$BORG_BACKUP_DIRECTORY" | grep "nextcloud-aio" | grep "$SELECTED_RESTORE_TIME" | awk -F " " '{print $1}' | head -1)"
172167
else
173168
SELECTED_ARCHIVE="$(borg list "$BORG_BACKUP_DIRECTORY" | grep "nextcloud-aio" | awk -F " " '{print $1}' | sort -r | head -1)"
174169
fi

Containers/borgbackup/start.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ if [ -z "$BORG_PASSWORD" ]; then
99
exit 1
1010
fi
1111

12-
export BORG_PASSWORD
12+
# Export defaults
13+
export BORG_PASSPHRASE="$BORG_PASSWORD"
14+
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
15+
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
1316

1417
# Validate BORG_MODE
1518
if [ "$BORG_MODE" != backup ] && [ "$BORG_MODE" != restore ] && [ "$BORG_MODE" != check ]; then

php/src/Data/ConfigurationManager.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function GetLastBackupTime() : string {
6464
}
6565

6666
$content = file_get_contents(DataConst::GetBackupArchivesList());
67-
if (count($content) === 0) {
67+
if ($content === '') {
6868
return '';
6969
}
7070

@@ -85,23 +85,25 @@ public function GetLastBackupTime() : string {
8585

8686
public function GetBackupTimes() : array {
8787
if (!file_exists(DataConst::GetBackupArchivesList())) {
88-
return $array[] = '';
88+
return [];
8989
}
9090

9191
$content = file_get_contents(DataConst::GetBackupArchivesList());
92-
if (count($content) === 0) {
93-
return $array[] = '';
92+
if ($content === '') {
93+
return [];
9494
}
9595

96-
$backupLines = explode('\n', $content);
96+
$backupLines = explode("\n", $content);
9797
$backupTimes = [];
9898
foreach($backupLines as $lines) {
99-
$backupTimesTemp = explode(',', $lines);
100-
$backupTimes[] = $backupTimesTemp[1];
99+
if ($lines !== "") {
100+
$backupTimesTemp = explode(',', $lines);
101+
$backupTimes[] = $backupTimesTemp[1];
102+
}
101103
}
102104

103105
if (!is_array($backupTimes)) {
104-
return $array[] = '';
106+
return [];
105107
}
106108

107109
return $backupTimes;

php/templates/containers.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
213213
<select id="selected_restore_time" name="selected_restore_time" form="restore_selection">
214214
{% for restore_time in backup_times %}
215-
<option value="{{ restore_time }}">{{ restore_time }}"</option>
215+
<option value="{{ restore_time }}">{{ restore_time }}</option>
216216
{% endfor %}
217217
</select>
218218
<input class="button" type="submit" value="Restore selected backup" onclick="return confirm('Restore the selected backup? Are you sure that you want to restore the selected backup? This will stop all running containers and restore the selected backup. It is recommended to create a backup first. You might also want to check the backup integrity.')" />

0 commit comments

Comments
 (0)