Download a backup's files or database
/v1/sites/{siteId}/backups/{backupId}/download Sends one part of a completed backup as a file: part=files, the site's files (a .tar.gz archive), or part=database, its database (a gzipped SQL dump). The file comes from the API whichever storage the backup is in, sent as it's read; its name is in Content-Disposition. Every download is written to the token's request log.
Limits. Only a backup with canDownload: one on an SFTP server is downloaded from that server, and one in Google Drive from its folder there (409 conflict, with the folder's link). Also 409 conflict: the storage refuses the file or no longer has it, or it has no IPv4 address (the API downloads only over IPv4). 60 downloads an hour per account, and 50 GB a day: once an account has downloaded that much today, a download answers 429 rate_limited until the day ends at 00:00 UTC (one that starts under it finishes).
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
sites:files - Files and logins. File Manager, WordPress logins, cron jobs, backup downloads and backup storage. Full access to the sites' code and data.
Path parameters
| Field | Type and description |
|---|---|
siteId Required | string The site's id. |
backupId Required | string The backup's id, from the site's backups. |
Query parameters
| Field | Type and description |
|---|---|
part Required | string The part to download: One of: |
Example request
curl "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/backups/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/download?part=database" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-OJ import { writeFile } from "node:fs/promises";
const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/backups/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/download?part=database", {
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
await writeFile("download", Buffer.from(await res.arrayBuffer())); import { writeFile } from "node:fs/promises";
import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const res = await rf.sites.backups.download({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
backupId: "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
part: "database",
});
await writeFile("download", Buffer.from(await res.arrayBuffer())); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/backups/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/download?part=database');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
file_put_contents('download', $body); import os
import requests
response = requests.get(
"https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/backups/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/download",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
params={
"part": "database",
},
timeout=120,
)
response.raise_for_status()
with open("download", "wb") as f:
f.write(response.content) Response
200 OK The answer is the file itself, as application/gzip, without the data envelope.
Example response
The file itself, as application/gzip, without the data envelope.
Errors
The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).
| Status and code | When, and what to do |
|---|---|
400 invalid_ | A query parameter is unknown or has a wrong value ( Correct or remove the parameter named in |
403 feature_ | This product isn't open to the account. Contact support if you'd like it opened. |
404 not_ | The resource doesn't exist, or isn't this account's. Check the id. Ids of other accounts' resources answer the same way. |
409 conflict | This clashes with something that exists, or is already done (for example, a domain already connected to a site). Read |
409 server_ | The server is being restored, and nothing else can change it or its sites until that's done. Wait until the restore finishes (the server's |
429 rate_ | Too many requests. Wait for Retry-After seconds, then go on more slowly. |
502 bad_ | Something on our side didn't answer properly. Try again in a moment. |