Skip to content

Commit 984a518

Browse files
committed
Added a new use case
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent 6df593d commit 984a518

File tree

4 files changed

+112
-15
lines changed

4 files changed

+112
-15
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Use Case: Automated Data Backup
2+
3+
## Overview
4+
5+
### System
6+
7+
This system automates the backup of an SQL Server database and uploads the backup file to a Minio object storage service on a regular schedule. The workflow consists of three main steps: exporting the database to a file, encoding the backup file in Base64 format, and uploading it to the Minio API.
8+
9+
### Actors
10+
11+
- **Database Administrator:** The user who configures and manages the workflow for database backups.
12+
- **SQL Server:** The database system from which the data is being exported.
13+
- **Minio Object Storage:** The service used for storing the backup files securely.
14+
- **Workflow Engine:** Orchestrates the execution of the defined tasks.
15+
16+
### Goals
17+
18+
- **Automated Backups:** To facilitate automated backups of critical database data without manual intervention, ensuring regular data protection.
19+
- **Data Security:** To ensure that backup files are securely uploaded to a reliable storage solution (Minio).
20+
- **Efficiency:** To streamline the backup process, reducing the time and effort required to perform database backups.
21+
22+
### Preconditions
23+
24+
- The SQL Server instance is accessible from the container environment.
25+
- The Minio object storage service is running and accessible via the provided endpoint.
26+
- Necessary permissions and credentials for both SQL Server and Minio are available.
27+
28+
## Scenario
29+
30+
### Triggers
31+
32+
The workflow is triggered automatically based on a cron schedule that executes the backup process daily at midnight.
33+
34+
### Flow Breakdown
35+
36+
1. **Export Database:**
37+
- A container runs the `mcr.microsoft.com/mssql-tools` image to back up the specified database to a file located in a mounted volume. The command utilizes environment variables to securely provide the SQL Server connection details and the database name.
38+
39+
2. **Read Backup File:**
40+
- Another container, using the Alpine image, reads the backup file from the mounted volume and encodes it in Base64. The Base64 encoded content is then exported for use in the next step.
41+
42+
3. **Upload to Minio:**
43+
- An HTTP call is made to the Minio API to upload the Base64 encoded backup file. The request includes the necessary authentication and specifies the content type as `application/octet-stream`.
44+
45+
### Visualization
46+
47+
The following diagram represents the high-level flow of the workflow:
48+
49+
![automated-data-backup-diagram](diagram.png)
50+
51+
*Visualization generated by Synapse.*
52+
53+
### Example
54+
55+
```yaml
56+
document:
57+
dsl: 1.0.0-alpha1
58+
namespace: default
59+
name: sql-export-to-minio
60+
version: 0.1.2
61+
do:
62+
- exportDatabase:
63+
run:
64+
container:
65+
image: mcr.microsoft.com/mssql-tools
66+
command: >
67+
/bin/bash -c "sqlcmd -S $SQLSERVER_HOST -U $SQLSERVER_USER -P '$SQLSERVER_PASSWORD' -Q 'BACKUP DATABASE [$DATABASE_NAME] TO DISK = N\'/var/backup/db.bak\'' && echo 'Database backup completed'"
68+
volumes:
69+
/var/backup: /backup
70+
environment:
71+
SQLSERVERHOST: sqlserver
72+
SQLSERVERUSER: SA
73+
SQLSERVERPASSWORD: P@ssw0rd
74+
DATABASENAME: YourDatabase
75+
- readBackupFile:
76+
run:
77+
container:
78+
image: alpine
79+
command: >
80+
/bin/sh -c "cat /backup/YourDatabase.bak | base64"
81+
volumes:
82+
/var/backup: /backup
83+
export:
84+
as: '$context + { base64Backup: . }'
85+
- uploadToMinio:
86+
call: http
87+
with:
88+
method: put
89+
endpoint:
90+
uri: https://minio.example.com/backups/db.bak
91+
authentication:
92+
bearer:
93+
token: 2548qsd5a8qsd43a
94+
headers:
95+
contentType: application/octet-stream
96+
body: ${ $context.base64Backup }
97+
schedule:
98+
cron: 0 0 * * *
99+
```
100+
101+
## Conclusion
102+
103+
This workflow effectively automates the process of backing up an SQL Server database and securely uploading it to a Minio storage solution, enhancing data management and security for database administrators.
37.1 KB
Loading

use-cases/multi-agent-ai-content-generation/README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,19 @@ document:
7070
namespace: default
7171
name: multi-agent-collaboration-for-ai-content
7272
version: '0.1.0'
73-
schedule:
74-
on:
75-
one:
76-
with:
77-
type: com.ai-content-generator.prompt.submitted.v1
73+
input:
74+
schema:
75+
document:
76+
type: object
77+
properties:
78+
prompt:
79+
type: string
80+
required: [ prompt ]
7881
do:
7982

8083
- initialize:
8184
set:
82-
prompt: ${ $workflow.input[0].data }
85+
prompt: ${ $workflow.input.prompt }
8386
export:
8487
as: .prompt
8588

@@ -165,15 +168,6 @@ do:
165168
text: ${ .text }
166169
image: ${ .image }
167170
then: end
168-
169-
- raiseUnsupportedEventError:
170-
raise:
171-
error:
172-
type: https://serverlessworkflow.io/spec/1.0.0/errors/runtime
173-
status: 400
174-
title: Unsupported Event
175-
detail: "The specified event is not supported in this context"
176-
then: end
177171
```
178172
179173
## Conclusion
107 KB
Loading

0 commit comments

Comments
 (0)