6 Commits

Author SHA1 Message Date
2aec03f580 upadte workflow
All checks were successful
Build Docker image / docker (push) Successful in 1m45s
Deploy to MicroK8s / deploy (push) Successful in 52s
2025-05-12 14:05:18 +03:00
9f818481d7 bump version
All checks were successful
Deploy to MicroK8s / deploy (push) Successful in 25s
2025-05-11 18:49:57 +03:00
33ea1411e1 add status and curl verbose
All checks were successful
Build Docker image / docker (push) Successful in 4m23s
2025-05-11 18:48:57 +03:00
9bb15825b1 bump version 2025-05-11 18:29:14 +03:00
fa961f48f0 add some logs
All checks were successful
Build Docker image / docker (push) Successful in 4m18s
2025-05-11 18:11:01 +03:00
44159904b2 update version 2025-05-11 17:23:28 +03:00
4 changed files with 14 additions and 6 deletions

View File

@@ -24,4 +24,6 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: git.mak-sim.ru/maksim/pg_backup:${{ gitea.ref_name }}
tags: |
git.mak-sim.ru/maksim/pg_backup:${{ gitea.ref_name }}
git.mak-sim.ru/maksim/pg_backup:latest

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
run.sh

View File

@@ -12,7 +12,7 @@ tasks:
cmds:
- |
helm upgrade --install -n system pg-backup ./pg_backup \
--set "image.tag=0.0.8" \
--set "image.tag=0.0.11" \
--set "postgres_host=db.mak-sim.ru" \
--set postgres_password=$POSTGRES_PASSWORD \
--set "aws_access_key_id=$AWS_ACCESS_KEY_ID" \

View File

@@ -15,18 +15,23 @@ POSTGRES_PORT="${POSTGRES_PORT:-5432}"
POSTGRES_SSL_MODE=${POSTGRES_SSL_MODE:-"require"}
RESTIC_TAG=${RESTIC_TAG:-"pg_basebackup"}
LOKI_URL="http://loki.montoring:3100/loki/api/v1/push"
LOKI_URL="http://loki.monitoring:3100/loki/api/v1/push"
SERVICE_NAME="pg_backup"
send_loki_status() {
local status="$1"
local timestamp_ns=$(date +%s%N)
curl -H "Content-Type: application/json" \
local level="info"
if [ "$status" = "failed" ]; then
level="error"
fi
curl -v -H "Content-Type: application/json" \
-s -X POST "$LOKI_URL" \
--data-raw "{
\"streams\": [
{
\"stream\": { \"service_name\": \"$SERVICE_NAME\" },
\"stream\": { \"service_name\": \"$SERVICE_NAME\", \"level\": \"$level\" },
\"values\": [
[ \"$timestamp_ns\", \"$status\" ]
]
@@ -39,6 +44,6 @@ trap 'send_loki_status failed' ERR
PGPASSWORD=${POSTGRES_PASSWORD} pg_basebackup -h "${POSTGRES_HOST}" -d "sslmode=${POSTGRES_SSL_MODE}" -D /tmp/backup -U ${POSTGRES_USER} -F t -z -P
restic --verbose backup -H ${RESTIC_HOST} --tag ${RESTIC_TAG} /tmp/backup
restic forget --prune --keep-last 14 --host ${RESTIC_HOST}
restic forget --prune --keep-within 14d --host ${RESTIC_HOST}
send_loki_status "done"