Skip to content

Commit 84e3153

Browse files
authored
Merge pull request pterodactyl#3179 from pterodactyl/fix/backup-restore
fix: backup restore delete all files
2 parents 62c08d1 + 5653b03 commit 84e3153

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

app/Http/Controllers/Api/Client/Servers/BackupController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function restore(Request $request, Server $server, Backup $backup): JsonR
213213
// actions against it via the Panel API.
214214
$server->update(['status' => Server::STATUS_RESTORING_BACKUP]);
215215

216-
$this->repository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate') === 'true');
216+
$this->repository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate'));
217217
});
218218

219219
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import http from '@/api/http';
22

3-
export const restoreServerBackup = async (uuid: string, backup: string): Promise<void> => {
4-
await http.post(`/api/client/servers/${uuid}/backups/${backup}/restore`);
3+
export const restoreServerBackup = async (uuid: string, backup: string, truncate?: boolean): Promise<void> => {
4+
await http.post(`/api/client/servers/${uuid}/backups/${backup}/restore`, {
5+
truncate,
6+
});
57
};

resources/scripts/components/server/backups/BackupContextMenu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default ({ backup }: Props) => {
2525
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
2626
const [ modal, setModal ] = useState('');
2727
const [ loading, setLoading ] = useState(false);
28+
const [ truncate, setTruncate ] = useState(false);
2829
const { clearFlashes, clearAndAddHttpError } = useFlash();
2930
const { mutate } = getServerBackups();
3031

@@ -62,7 +63,7 @@ export default ({ backup }: Props) => {
6263
const doRestorationAction = () => {
6364
setLoading(true);
6465
clearFlashes('backups');
65-
restoreServerBackup(uuid, backup.uuid)
66+
restoreServerBackup(uuid, backup.uuid, truncate)
6667
.then(() => setServerFromState(s => ({
6768
...s,
6869
status: 'restoring_backup',
@@ -108,6 +109,8 @@ export default ({ backup }: Props) => {
108109
css={tw`text-red-500! w-5! h-5! mr-2`}
109110
id={'restore_truncate'}
110111
value={'true'}
112+
checked={truncate}
113+
onChange={() => setTruncate(s => !s)}
111114
/>
112115
Remove all files and folders before restoring this backup.
113116
</label>

0 commit comments

Comments
 (0)