Skip to content

Commit 73c5def

Browse files
SamyOubouazizthomas-tacquetjcirinosclwy
authored
docs(srv): add RDB backups using jobs MTA-6140 (#5109)
* docs(srv): update * docs(srv): update * Update tutorials/snapshot-managed-databases/index.mdx Co-authored-by: Thomas TACQUET <[email protected]> * Update tutorials/snapshot-managed-databases/index.mdx Co-authored-by: Jessica <[email protected]> --------- Co-authored-by: Thomas TACQUET <[email protected]> Co-authored-by: Jessica <[email protected]>
1 parent c2b8d3e commit 73c5def

File tree

3 files changed

+105
-12
lines changed

3 files changed

+105
-12
lines changed

tutorials/power-on-off-instances-jobs/index.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n
5454

5555
For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server).
5656

57-
9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID:
57+
9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Instance:
5858

5959
```
6060
scw instance server start 11111111-1111-1111-1111-111111111111
@@ -85,15 +85,15 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n
8585
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
8686
- `SCW_DEFAULT_REGION`: the preferred region.
8787

88-
<Message type="note">
89-
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
90-
</Message>
88+
<Message type="note">
89+
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
90+
</Message>
9191

92-
For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server).
92+
For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server).
9393

94-
9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID:
94+
9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Instance:
9595

96-
```
96+
```sh
9797
scw instance server stop 11111111-1111-1111-1111-111111111111
9898
```
9999

tutorials/snapshot-instances-jobs/index.mdx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n
4646
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
4747
- `SCW_DEFAULT_REGION`: concerned region.
4848

49-
<Message type="note">
50-
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
51-
</Message>
49+
<Message type="note">
50+
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
51+
</Message>
5252

53-
For more details about variables used by `cli`, refer to the [CLI config documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md).
53+
For more details about variables used by `cli`, refer to the [CLI config documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md).
5454

55-
9. In the **Execution** tab, define the desired command: `/scw block snapshot create volume-id=11111111-1111-1111-1111-111111111111` (replace the ID with your desired volume ID).
55+
9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Block Storage volume:
56+
```sh
57+
scw block snapshot create volume-id=11111111-1111-1111-1111-111111111111
58+
```
5659

5760
10. Click **Create job**.
5861

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
meta:
3+
title: Create recurring scheduled backups and snapshots of a database with Serverless Jobs and the Scaleway CLI
4+
description: This step-by-step tutorial will help you automate the creation and scheduling of backups and snapshots of your database using Serverless Jobs and the Scaleway CLI
5+
content:
6+
h1: Create recurring scheduled backups and snapshots of a database with Serverless Jobs and the Scaleway CLI
7+
paragraph: This step-by-step tutorial will help you automate the creation and scheduling of backups and snapshots of your database using Serverless Jobs and the Scaleway CLI
8+
tags: serverless jobs instance snapshot backup image disk storage cli schedule cron recurring
9+
categories:
10+
- instances
11+
- jobs
12+
dates:
13+
validation: 2025-06-12
14+
posted: 2024-06-19
15+
---
16+
17+
[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This tutorial will guide you through the process of creating backups and snapshots of a [Managed Database](/managed-databases-for-postgresql-and-mysql/quickstart/) on a recurring schedule using a serverless job.
18+
19+
Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not need autoscaling or exposure via a web server. Refer to the [documentation on differences between jobs, containers, and functions](/serverless-jobs/reference-content/difference-jobs-functions-containers/) for more information.
20+
21+
<Macro id="requirements" />
22+
23+
- A Scaleway account logged into the [console](https://console.scaleway.com).
24+
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization.
25+
- Created a [managed database](/classic-hosting/how-to/create-postgresql-database/).
26+
27+
## Creating the job definition
28+
29+
1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays.
30+
31+
2. Click **Create job**. The job creation wizard displays.
32+
33+
3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`.
34+
35+
4. Enter a name or use the automatically generated one.
36+
37+
5. Select the region in which your job will be created.
38+
39+
6. Keep the default **resources** values, as this job requires little compute capability.
40+
41+
7. Set **cron schedule** to `0 18 * * *` and select the relevant time zone to run the job every evening at 18:00. Refer to the [cron schedules documentation](/serverless-jobs/reference-content/cron-schedules/) for more information.
42+
43+
8. Define the following environment variables:
44+
- `SCW_ACCESS_KEY`: your API access key.
45+
- `SCW_SECRET_KEY`: your API secret key.
46+
- `SCW_DEFAULT_PROJECT_ID`: your Project ID.
47+
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
48+
- `SCW_DEFAULT_REGION`: concerned region.
49+
50+
<Message type="note">
51+
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
52+
</Message>
53+
54+
For more details about variables used by `cli`, refer to the [CLI config documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md).
55+
56+
9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Database Instance:
57+
<Tabs>
58+
<TabsTab label="Backup">
59+
```sh
60+
scw rdb backup create instance-id=11111111-1111-1111-1111-111111111111 database-name=YOUR_DB_NAME
61+
```
62+
</TabsTab>
63+
<TabsTab label="Snapshot">
64+
```sh
65+
scw rdb snapshot create instance-id=11111111-1111-1111-1111-111111111111
66+
```
67+
</TabsTab>
68+
</Tabs>
69+
10. Click **Create job**.
70+
71+
## Running the job
72+
73+
From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu.
74+
75+
The execution appears in the **Job runs** section. You can access the logs of your job by clicking <Icon name="more" /> next to the job run ID, and selecting **See on Cockpit**.
76+
77+
## Possible improvements
78+
79+
This tutorial is a lightweight example of how to create recurring backups and snapshots of a Managed Database for PostgreSQL and MySQL. You can go further by:
80+
- Using it to manage all your Databases' backups and snapshots
81+
- Creating other recurring database operations
82+
- Setting up an alerting system in case of unexpected behavior
83+
- Explore [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples
84+
85+
## Additional resources
86+
87+
- [Serverless Jobs Documentation](/serverless-jobs/how-to/create-job/)
88+
- [Other methods to deploy Jobs](/serverless-jobs/reference-content/deploy-job/)
89+
- [API keys documentation](/iam/how-to/create-api-keys/)
90+
- [CRON schedule reference](/serverless-jobs/reference-content/cron-schedules/)

0 commit comments

Comments
 (0)