12 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
deb90b0e50 add curl
All checks were successful
Build Docker image / docker (push) Successful in 1m41s
2025-05-11 17:19:18 +03:00
a49c4c4526 update version 2025-05-11 17:11:25 +03:00
9c2918254c add loki
All checks were successful
Build Docker image / docker (push) Successful in 1m39s
2025-05-11 17:08:04 +03:00
f2cdb2c3f6 update version 2025-05-11 13:47:45 +03:00
58ac517bbf update version
All checks were successful
Build Docker image / docker (push) Successful in 1m35s
2025-05-11 13:43:46 +03:00
0abc8f3502 add workflow deps 2025-05-11 13:41:39 +03:00
6 changed files with 38 additions and 5 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

@@ -3,7 +3,7 @@ FROM postgres:17
WORKDIR /root
RUN apt update && \
apt -y install restic ca-certificates
apt -y install restic ca-certificates curl
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

View File

@@ -12,6 +12,7 @@ tasks:
cmds:
- |
helm upgrade --install -n system pg-backup ./pg_backup \
--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,6 +15,35 @@ POSTGRES_PORT="${POSTGRES_PORT:-5432}"
POSTGRES_SSL_MODE=${POSTGRES_SSL_MODE:-"require"}
RESTIC_TAG=${RESTIC_TAG:-"pg_basebackup"}
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)
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\", \"level\": \"$level\" },
\"values\": [
[ \"$timestamp_ns\", \"$status\" ]
]
}
]
}"
}
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"

View File

@@ -1,7 +1,7 @@
image:
repository: git.mak-sim.ru/maksim/pg_backup
pullPolicy: IfNotPresent
tag: "0.0.6"
tag: "0.0.7"
imagePullSecrets:
- name: regcred