Skip to content
AquadactylAquadactyl
API referenceClient API

Backups

7 source-verified client API operations in Aquadactyl.

Generated from Aquadactyl 2bfd6ae2a30c. Read authentication and conventions first.

GET /api/client/servers/{server}/backups

Returns all the backups for a given server instance in a paginated result set.

Access: Client API key or authenticated panel session.

Source: Route · Controller

Path parameters: server. See identifiers.

Other controller inputs: per_page.

Response

Success: 200. Response attributes: Client BackupTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
    throw new AuthorizationException();
}

$limit = min($request->query('per_page') ?? 20, 50);

return $this->fractal->collection($server->backups()->paginate($limit))
    ->transformWith($this->getTransformer(BackupTransformer::class))
    ->addMeta([
        'backup_count' => $this->repository->getNonFailedBackups($server)->count(),
    ])
    ->toArray();

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/backups" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json"

POST /api/client/servers/{server}/backups

Starts the backup process for a server.

Access: Client API key or authenticated panel session; backup.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
name'nullable|string|max:191'
is_locked'nullable|boolean'
ignored'nullable|string'

Response

Success: 200. Response attributes: Client BackupTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$action = $this->initiateBackupService
    ->setIgnoredFiles(explode(PHP_EOL, $request->input('ignored') ?? ''));

if ($request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
    $action->setIsLocked($request->boolean('is_locked'));
}

$backup = Activity::event('server:backup.start')->transaction(function ($log) use ($action, $server, $request) {
    $server->backups()->lockForUpdate()->count();

    $backup = $action->handle($server, $request->input('name'));

    $log->subject($backup)->property([
        'name' => $backup->name,
        'locked' => $request->boolean('is_locked'),
    ]);

    return $backup;
});

return $this->fractal->item($backup)
    ->transformWith($this->getTransformer(BackupTransformer::class))
    ->toArray();

GET /api/client/servers/{server}/backups/{backup}

Returns information about a single backup.

Access: Client API key or authenticated panel session.

Source: Route · Controller

Path parameters: server, backup. See identifiers.

Response

Success: 200. Response attributes: Client BackupTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
    throw new AuthorizationException();
}

return $this->fractal->item($backup)
    ->transformWith($this->getTransformer(BackupTransformer::class))
    ->toArray();

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/backups/RESOURCE_ID" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json"

GET /api/client/servers/{server}/backups/{backup}/download

Download the backup for a given server instance. For daemon local files, the file will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated which the user is redirected to.

Access: Client API key or authenticated panel session.

Source: Route · Controller

Path parameters: server, backup. See identifiers.

Response

Success: 200.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!$request->user()->can(Permission::ACTION_BACKUP_DOWNLOAD, $server)) {
    throw new AuthorizationException();
}

if ($backup->disk !== Backup::ADAPTER_AWS_S3 && $backup->disk !== Backup::ADAPTER_WINGS) {
    throw new BadRequestHttpException('The backup requested references an unknown disk driver type and cannot be downloaded.');
}

$url = $this->downloadLinkService->handle($backup, $request->user());

Activity::event('server:backup.download')->subject($backup)->property('name', $backup->name)->log();

return new JsonResponse([
    'object' => 'signed_url',
    'attributes' => ['url' => $url],
]);

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/backups/RESOURCE_ID/download" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json"

POST /api/client/servers/{server}/backups/{backup}/lock

Toggles the lock status of a given backup for a server.

Access: Client API key or authenticated panel session.

Source: Route · Controller

Path parameters: server, backup. See identifiers.

Response

Success: 200. Response attributes: Client BackupTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
    throw new AuthorizationException();
}

$action = $backup->is_locked ? 'server:backup.unlock' : 'server:backup.lock';

$backup->update(['is_locked' => !$backup->is_locked]);

Activity::event($action)->subject($backup)->property('name', $backup->name)->log();

return $this->fractal->item($backup)
    ->transformWith($this->getTransformer(BackupTransformer::class))
    ->toArray();

POST /api/client/servers/{server}/backups/{backup}/restore

Handles restoring a backup by making a request to the Wings instance telling it to begin the process of finding (or downloading) the backup and unpacking it over the server files. If the "truncate" flag is passed through in this request then all the files that currently exist on the server will be deleted before restoring. Otherwise, the archive will simply be unpacked over the existing files.

Access: Client API key or authenticated panel session; backup.restore.

Source: Route · Controller · Request validation

Path parameters: server, backup. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
truncate'required|boolean'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!is_null($server->status)) {
    throw new BadRequestHttpException('This server is not currently in a state that allows for a backup to be restored.');
}

if (!$backup->is_successful || is_null($backup->completed_at)) {
    throw new BadRequestHttpException('This backup cannot be restored at this time: not completed or failed.');
}

$log = Activity::event('server:backup.restore')
    ->subject($backup)
    ->property(['name' => $backup->name, 'truncate' => $request->input('truncate')]);

$log->transaction(function () use ($backup, $server, $request) {

    if ($backup->disk === Backup::ADAPTER_AWS_S3) {
        $url = $this->downloadLinkService->handle($backup, $request->user());
    }

    $server->update(['status' => Server::STATUS_RESTORING_BACKUP]);

    $this->daemonRepository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate'));
});

return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);

DELETE /api/client/servers/{server}/backups/{backup}

Deletes a backup from the panel as well as the remote source where it is currently being stored.

Access: Client API key or authenticated panel session.

Source: Route · Controller

Path parameters: server, backup. See identifiers.

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
    throw new AuthorizationException();
}

$this->deleteBackupService->handle($backup);

Activity::event('server:backup.delete')
    ->subject($backup)
    ->property(['name' => $backup->name, 'failed' => !$backup->is_successful])
    ->log();

return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);