mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 17:12:30 +01:00
fix: backup restore delete all files
This commit is contained in:
parent
c8c9c3d3cb
commit
582521f419
@ -213,7 +213,7 @@ class BackupController extends ClientApiController
|
|||||||
// actions against it via the Panel API.
|
// actions against it via the Panel API.
|
||||||
$server->update(['status' => Server::STATUS_RESTORING_BACKUP]);
|
$server->update(['status' => Server::STATUS_RESTORING_BACKUP]);
|
||||||
|
|
||||||
$this->repository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate') === 'true');
|
$this->repository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate'));
|
||||||
});
|
});
|
||||||
|
|
||||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import http from '@/api/http';
|
import http from '@/api/http';
|
||||||
|
|
||||||
export const restoreServerBackup = async (uuid: string, backup: string): Promise<void> => {
|
export const restoreServerBackup = async (uuid: string, backup: string, truncate?: boolean): Promise<void> => {
|
||||||
await http.post(`/api/client/servers/${uuid}/backups/${backup}/restore`);
|
await http.post(`/api/client/servers/${uuid}/backups/${backup}/restore`, {
|
||||||
|
truncate,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@ -25,6 +25,7 @@ export default ({ backup }: Props) => {
|
|||||||
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
||||||
const [ modal, setModal ] = useState('');
|
const [ modal, setModal ] = useState('');
|
||||||
const [ loading, setLoading ] = useState(false);
|
const [ loading, setLoading ] = useState(false);
|
||||||
|
const [ truncate, setTruncate ] = useState(false);
|
||||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||||
const { mutate } = getServerBackups();
|
const { mutate } = getServerBackups();
|
||||||
|
|
||||||
@ -59,10 +60,10 @@ export default ({ backup }: Props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const doRestorationAction = () => {
|
const doRestorationAction = (truncate: boolean) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
clearFlashes('backups');
|
clearFlashes('backups');
|
||||||
restoreServerBackup(uuid, backup.uuid)
|
restoreServerBackup(uuid, backup.uuid, truncate)
|
||||||
.then(() => setServerFromState(s => ({
|
.then(() => setServerFromState(s => ({
|
||||||
...s,
|
...s,
|
||||||
status: 'restoring_backup',
|
status: 'restoring_backup',
|
||||||
@ -87,7 +88,7 @@ export default ({ backup }: Props) => {
|
|||||||
visible={modal === 'restore'}
|
visible={modal === 'restore'}
|
||||||
title={'Restore this backup?'}
|
title={'Restore this backup?'}
|
||||||
buttonText={'Restore backup'}
|
buttonText={'Restore backup'}
|
||||||
onConfirmed={() => doRestorationAction()}
|
onConfirmed={() => doRestorationAction(truncate)}
|
||||||
onModalDismissed={() => setModal('')}
|
onModalDismissed={() => setModal('')}
|
||||||
>
|
>
|
||||||
<p css={tw`text-neutral-300`}>
|
<p css={tw`text-neutral-300`}>
|
||||||
@ -108,6 +109,8 @@ export default ({ backup }: Props) => {
|
|||||||
css={tw`text-red-500! w-5! h-5! mr-2`}
|
css={tw`text-red-500! w-5! h-5! mr-2`}
|
||||||
id={'restore_truncate'}
|
id={'restore_truncate'}
|
||||||
value={'true'}
|
value={'true'}
|
||||||
|
checked={truncate}
|
||||||
|
onChange={() => setTruncate(!truncate)}
|
||||||
/>
|
/>
|
||||||
Remove all files and folders before restoring this backup.
|
Remove all files and folders before restoring this backup.
|
||||||
</label>
|
</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user