From f77699c4c014d277a9bd5280bdb735cdb99c7b09 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Thu, 12 Jun 2025 13:31:35 +0200 Subject: [PATCH 1/4] docs(srv): update --- .../power-on-off-instances-jobs/index.mdx | 14 +-- tutorials/snapshot-instances-jobs/index.mdx | 13 +-- .../snapshot-managed-databases/index.mdx | 89 +++++++++++++++++++ 3 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 tutorials/snapshot-managed-databases/index.mdx diff --git a/tutorials/power-on-off-instances-jobs/index.mdx b/tutorials/power-on-off-instances-jobs/index.mdx index de03c917aa..9010b41913 100644 --- a/tutorials/power-on-off-instances-jobs/index.mdx +++ b/tutorials/power-on-off-instances-jobs/index.mdx @@ -54,7 +54,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server). -9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID: +9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Instance: ``` 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 - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. - `SCW_DEFAULT_REGION`: the preferred region. - - We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. - + + We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. + - For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server). + For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server). -9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID: +9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Instance: - ``` + ```sh scw instance server stop 11111111-1111-1111-1111-111111111111 ``` diff --git a/tutorials/snapshot-instances-jobs/index.mdx b/tutorials/snapshot-instances-jobs/index.mdx index 4b81288189..068499c8bf 100644 --- a/tutorials/snapshot-instances-jobs/index.mdx +++ b/tutorials/snapshot-instances-jobs/index.mdx @@ -46,13 +46,16 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. - `SCW_DEFAULT_REGION`: concerned region. - - We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. - + + We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. + -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). + 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). -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). +9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Block Storage volume: + ```sh + scw block snapshot create volume-id=11111111-1111-1111-1111-111111111111 + ``` 10. Click **Create job**. diff --git a/tutorials/snapshot-managed-databases/index.mdx b/tutorials/snapshot-managed-databases/index.mdx new file mode 100644 index 0000000000..bdf7d724fd --- /dev/null +++ b/tutorials/snapshot-managed-databases/index.mdx @@ -0,0 +1,89 @@ +--- +meta: + title: Create recurring scheduled backups and snapshots of a database with Serverless Jobs and the Scaleway CLI + 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 +content: + h1: Create recurring scheduled backups and snapshots of a database with Serverless Jobs and the Scaleway CLI + 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 +tags: serverless jobs instance snapshot backup image disk storage cli schedule cron recurring +categories: + - instances + - jobs +dates: + validation: 2025-03-12 + posted: 2024-06-19 +--- +[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. + +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. + + + +- A Scaleway account logged into the [console](https://console.scaleway.com). +- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization. +- Created a [managed database](/classic-hosting/how-to/create-postgresql-database/). + +## Creating the job definition + +1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays. + +2. Click **Create job**. The job creation wizard displays. + +3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`. + +4. Enter a name or use the automatically generated one. + +5. Select the region in which your job will be created. + +6. Keep the default **resources** values, as this job requires little compute capability. + +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. + +8. Define the following environment variables: + - `SCW_ACCESS_KEY`: your API access key. + - `SCW_SECRET_KEY`: your API secret key. + - `SCW_DEFAULT_PROJECT_ID`: your Project ID. + - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. + - `SCW_DEFAULT_REGION`: concerned region. + + + We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. + + + 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). + +9. In the **Execution** tab, define the command below, and replace the placeholder with the ID of your Database Instance: + + + ```sh + scw rdb backup create instance-id=11111111-1111-1111-1111-111111111111 + ``` + + + ```sh + scw rdb snapshot create instance-id=11111111-1111-1111-1111-111111111111 + ``` + + +10. Click **Create job**. + +## Running the job + +From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu. + +The execution appears in the **Job runs** section. You can access the logs of your job by clicking next to the job run ID, and selecting **See on Cockpit**. + +## Possible improvements + +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: +- Using it to manage all your Databases' backups and snapshots +- Creating other recurring database operations +- Setting up an alerting system in case of unexpected behavior +- Explore [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples + +## Additional resources + +- [Serverless Jobs Documentation](/serverless-jobs/how-to/create-job/) +- [Other methods to deploy Jobs](/serverless-jobs/reference-content/deploy-job/) +- [API keys documentation](/iam/how-to/create-api-keys/) +- [CRON schedule reference](/serverless-jobs/reference-content/cron-schedules/) From ed5f90c24088f12e53a981545fa2484c75e38cd7 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Thu, 12 Jun 2025 13:32:44 +0200 Subject: [PATCH 2/4] docs(srv): update --- tutorials/snapshot-managed-databases/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/snapshot-managed-databases/index.mdx b/tutorials/snapshot-managed-databases/index.mdx index bdf7d724fd..fa78b7ab99 100644 --- a/tutorials/snapshot-managed-databases/index.mdx +++ b/tutorials/snapshot-managed-databases/index.mdx @@ -10,7 +10,7 @@ categories: - instances - jobs dates: - validation: 2025-03-12 + validation: 2025-06-12 posted: 2024-06-19 --- [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. From 5a6069ad739ce087ce2ec1dbeb85b34e8fdadf8d Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Thu, 12 Jun 2025 17:25:26 +0200 Subject: [PATCH 3/4] Update tutorials/snapshot-managed-databases/index.mdx Co-authored-by: Thomas TACQUET --- tutorials/snapshot-managed-databases/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/snapshot-managed-databases/index.mdx b/tutorials/snapshot-managed-databases/index.mdx index fa78b7ab99..d6b2259814 100644 --- a/tutorials/snapshot-managed-databases/index.mdx +++ b/tutorials/snapshot-managed-databases/index.mdx @@ -56,7 +56,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n ```sh - scw rdb backup create instance-id=11111111-1111-1111-1111-111111111111 + scw rdb backup create instance-id=11111111-1111-1111-1111-111111111111 database-name=YOUR_DB_NAME ``` From 2c810fb89982cdf33d0baa0d097725a05ed95e42 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Thu, 12 Jun 2025 17:25:33 +0200 Subject: [PATCH 4/4] Update tutorials/snapshot-managed-databases/index.mdx Co-authored-by: Jessica <113192637+jcirinosclwy@users.noreply.github.com> --- tutorials/snapshot-managed-databases/index.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/snapshot-managed-databases/index.mdx b/tutorials/snapshot-managed-databases/index.mdx index d6b2259814..2c50233dec 100644 --- a/tutorials/snapshot-managed-databases/index.mdx +++ b/tutorials/snapshot-managed-databases/index.mdx @@ -13,7 +13,8 @@ dates: validation: 2025-06-12 posted: 2024-06-19 --- -[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. + +[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. 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.