fix: more backup errors
All checks were successful
Deploy to Staging / Build Images (push) Successful in 2m35s
Deploy to Staging / Deploy to Staging (push) Successful in 37s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 2m35s
Deploy to Staging / Deploy to Staging (push) Successful in 37s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -408,13 +408,23 @@ export const adminApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Execute restore
|
||||
// Execute restore (longer timeout since this is a long-running operation)
|
||||
restore: async (id: string, options?: ExecuteRestoreRequest): Promise<{ message: string }> => {
|
||||
const response = await apiClient.post<{ message: string }>(
|
||||
`/admin/backups/${id}/restore`,
|
||||
options
|
||||
);
|
||||
return response.data;
|
||||
try {
|
||||
const response = await apiClient.post<{ message: string }>(
|
||||
`/admin/backups/${id}/restore`,
|
||||
options,
|
||||
{ timeout: 120000 } // 2 minute timeout for restore operations
|
||||
);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
// If a restore is already in progress, treat it as success since it will complete
|
||||
const errorMessage = error?.response?.data?.error || error?.message || '';
|
||||
if (errorMessage.includes('already in progress')) {
|
||||
return { message: 'Restore is in progress and will complete shortly' };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// Schedules
|
||||
|
||||
@@ -147,6 +147,7 @@ export const useExecuteRestore = () => {
|
||||
return useMutation({
|
||||
mutationFn: ({ id, options }: { id: string; options?: ExecuteRestoreRequest }) =>
|
||||
adminApi.backups.restore(id, options),
|
||||
retry: false,
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: backupKeys.all });
|
||||
toast.success(data.message || 'Restore completed successfully');
|
||||
|
||||
@@ -152,7 +152,7 @@ export const AdminBackupMobileScreen: React.FC = () => {
|
||||
);
|
||||
|
||||
const handleExecuteRestore = useCallback(() => {
|
||||
if (!selectedBackup) return;
|
||||
if (!selectedBackup || executeRestoreMutation.isPending) return;
|
||||
executeRestoreMutation.mutate(
|
||||
{ id: selectedBackup.id, options: { createSafetyBackup } },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user