67 lines
1.7 KiB
Markdown
67 lines
1.7 KiB
Markdown
# Prefect Flows - PostgreSQL Backup
|
|
|
|
Flows Prefect pour la sauvegarde automatisée de bases PostgreSQL vers S3 (Garage).
|
|
|
|
## Structure
|
|
|
|
```
|
|
prefect-flows-pg-backup/
|
|
├── flows/
|
|
│ └── backup.py # Flow principal de backup
|
|
├── deploy.py # Script de déploiement
|
|
├── setup_blocks.py # Création des Prefect Blocks
|
|
├── requirements.txt
|
|
└── README.md
|
|
```
|
|
|
|
## Déploiement automatique (CI/CD)
|
|
|
|
Le workflow Gitea Actions crée les Blocks et déploie les flows automatiquement sur push vers `main`.
|
|
|
|
### Secrets requis dans Gitea
|
|
|
|
Dans **Settings → Secrets**, ajouter :
|
|
|
|
| Secret | Description |
|
|
|--------|-------------|
|
|
| `PREFECT_API_URL` | `https://prefect.taila5ad8.ts.net/api` |
|
|
| `S3_ACCESS_KEY` | Access key Garage |
|
|
| `S3_SECRET_KEY` | Secret key Garage |
|
|
| `S3_ENDPOINT_URL` | `https://s3.taila5ad8.ts.net` |
|
|
| `PG_PASSWORD` | Mot de passe PostgreSQL (netbox) |
|
|
|
|
## Déploiement manuel
|
|
|
|
```bash
|
|
export PREFECT_API_URL=https://prefect.taila5ad8.ts.net/api
|
|
export AWS_ACCESS_KEY_ID=xxx
|
|
export AWS_SECRET_ACCESS_KEY=xxx
|
|
export AWS_ENDPOINT_URL=https://s3.taila5ad8.ts.net
|
|
export PG_PASSWORD=xxx
|
|
|
|
python setup_blocks.py
|
|
python deploy.py
|
|
```
|
|
|
|
## Blocks créés
|
|
|
|
| Block | Type | Usage |
|
|
|-------|------|-------|
|
|
| `garage-credentials` | `AwsCredentials` | Credentials S3 pour Garage |
|
|
| `netbox-db-password` | `Secret` | Mot de passe PostgreSQL |
|
|
|
|
## Flows déployés
|
|
|
|
| Flow | Schedule | Description |
|
|
|------|----------|-------------|
|
|
| `pg-backup-daily` | `0 2 * * *` | Backup quotidien à 2h |
|
|
|
|
## Lancement manuel
|
|
|
|
Dans l'UI Prefect : **Deployments** → **pg-backup-daily** → **Run** → **Quick Run**
|
|
|
|
Ou via CLI :
|
|
```bash
|
|
prefect deployment run 'pg-backup/pg-backup-daily'
|
|
```
|