Restore a PostgreSQL database
curl --request POST \
--url https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"restore_target": "2023-11-07T05:31:56Z",
"pg_config": {
"max_connections": "100"
},
"pgbouncer_config": {
"max_client_conn": "100"
},
"private_subnet_ipv4_range": "10.20.0.0/20",
"tags": [
{
"key": "<string>",
"value": "<string>"
}
]
}
'import requests
url = "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore"
payload = {
"name": "<string>",
"restore_target": "2023-11-07T05:31:56Z",
"pg_config": { "max_connections": "100" },
"pgbouncer_config": { "max_client_conn": "100" },
"private_subnet_ipv4_range": "10.20.0.0/20",
"tags": [
{
"key": "<string>",
"value": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
restore_target: '2023-11-07T05:31:56Z',
pg_config: {max_connections: '100'},
pgbouncer_config: {max_client_conn: '100'},
private_subnet_ipv4_range: '10.20.0.0/20',
tags: [{key: '<string>', value: '<string>'}]
})
};
fetch('https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'restore_target' => '2023-11-07T05:31:56Z',
'pg_config' => [
'max_connections' => '100'
],
'pgbouncer_config' => [
'max_client_conn' => '100'
],
'private_subnet_ipv4_range' => '10.20.0.0/20',
'tags' => [
[
'key' => '<string>',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"flavor": "<string>",
"ha_type": "<string>",
"target_server_count": 123,
"id": "pgn30gjk1d1e2jj34v9x0dq4rp",
"location": "<string>",
"name": "<string>",
"state": "<string>",
"storage_size_gib": 123,
"version": "16",
"target_version": "16",
"vm_size": "<string>",
"maintenance_window_start_at": 123,
"read_replica": true,
"fallback_active": true,
"tags": [
{
"key": "<string>",
"value": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"connection_string": "<string>",
"private_connection_string": "<string>",
"username": "<string>",
"password": "<string>",
"hostname": "<string>",
"earliest_restore_time": "<string>",
"firewall_rules": [
{
"cidr": "<string>",
"id": "frmjgkgbktw62k53005jpx8tt7",
"description": "<string>",
"port": 123
}
],
"latest_restore_time": "<string>",
"primary": true,
"target_storage_size_gib": 123,
"target_vm_size": "<string>",
"ca_certificates": "<string>",
"maintenance_window_days": [
"mon"
],
"parent": "<string>"
}{
"error": {
"code": 401,
"message": "There was an error logging in",
"type": "InvalidCredentials",
"details": {}
}
}Postgres Database
Restore a PostgreSQL database
POST
/
project
/
{project_id}
/
location
/
{location}
/
postgres
/
{postgres_database_reference}
/
restore
Restore a PostgreSQL database
curl --request POST \
--url https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"restore_target": "2023-11-07T05:31:56Z",
"pg_config": {
"max_connections": "100"
},
"pgbouncer_config": {
"max_client_conn": "100"
},
"private_subnet_ipv4_range": "10.20.0.0/20",
"tags": [
{
"key": "<string>",
"value": "<string>"
}
]
}
'import requests
url = "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore"
payload = {
"name": "<string>",
"restore_target": "2023-11-07T05:31:56Z",
"pg_config": { "max_connections": "100" },
"pgbouncer_config": { "max_client_conn": "100" },
"private_subnet_ipv4_range": "10.20.0.0/20",
"tags": [
{
"key": "<string>",
"value": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
restore_target: '2023-11-07T05:31:56Z',
pg_config: {max_connections: '100'},
pgbouncer_config: {max_client_conn: '100'},
private_subnet_ipv4_range: '10.20.0.0/20',
tags: [{key: '<string>', value: '<string>'}]
})
};
fetch('https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'restore_target' => '2023-11-07T05:31:56Z',
'pg_config' => [
'max_connections' => '100'
],
'pgbouncer_config' => [
'max_client_conn' => '100'
],
'private_subnet_ipv4_range' => '10.20.0.0/20',
'tags' => [
[
'key' => '<string>',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ubicloud.com/project/{project_id}/location/{location}/postgres/{postgres_database_reference}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"restore_target\": \"2023-11-07T05:31:56Z\",\n \"pg_config\": {\n \"max_connections\": \"100\"\n },\n \"pgbouncer_config\": {\n \"max_client_conn\": \"100\"\n },\n \"private_subnet_ipv4_range\": \"10.20.0.0/20\",\n \"tags\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"flavor": "<string>",
"ha_type": "<string>",
"target_server_count": 123,
"id": "pgn30gjk1d1e2jj34v9x0dq4rp",
"location": "<string>",
"name": "<string>",
"state": "<string>",
"storage_size_gib": 123,
"version": "16",
"target_version": "16",
"vm_size": "<string>",
"maintenance_window_start_at": 123,
"read_replica": true,
"fallback_active": true,
"tags": [
{
"key": "<string>",
"value": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"connection_string": "<string>",
"private_connection_string": "<string>",
"username": "<string>",
"password": "<string>",
"hostname": "<string>",
"earliest_restore_time": "<string>",
"firewall_rules": [
{
"cidr": "<string>",
"id": "frmjgkgbktw62k53005jpx8tt7",
"description": "<string>",
"port": 123
}
],
"latest_restore_time": "<string>",
"primary": true,
"target_storage_size_gib": 123,
"target_vm_size": "<string>",
"ca_certificates": "<string>",
"maintenance_window_days": [
"mon"
],
"parent": "<string>"
}{
"error": {
"code": 401,
"message": "There was an error logging in",
"type": "InvalidCredentials",
"details": {}
}
}Authorizations
Path Parameters
Body
application/json
IPv4 range of the restored database's private subnet, from /16 to /26 (/16 to /24 in AWS locations) inside 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16, not overlapping another private subnet of the project in the location. A random range is used if not provided.
Example:
"10.20.0.0/20"
Response
A Postgres Database