Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
2aec03f580
|
|||
|
9f818481d7
|
|||
|
33ea1411e1
|
|||
|
9bb15825b1
|
|||
|
fa961f48f0
|
|||
|
44159904b2
|
|||
|
deb90b0e50
|
|||
|
a49c4c4526
|
|||
|
9c2918254c
|
|||
|
f2cdb2c3f6
|
|||
|
58ac517bbf
|
|||
|
0abc8f3502
|
@@ -24,4 +24,6 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
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
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
run.sh
|
||||||
@@ -3,7 +3,7 @@ FROM postgres:17
|
|||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
|
|
||||||
RUN apt update && \
|
RUN apt update && \
|
||||||
apt -y install restic ca-certificates
|
apt -y install restic ca-certificates curl
|
||||||
|
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
helm upgrade --install -n system pg-backup ./pg_backup \
|
helm upgrade --install -n system pg-backup ./pg_backup \
|
||||||
|
--set "image.tag=0.0.11" \
|
||||||
--set "postgres_host=db.mak-sim.ru" \
|
--set "postgres_host=db.mak-sim.ru" \
|
||||||
--set postgres_password=$POSTGRES_PASSWORD \
|
--set postgres_password=$POSTGRES_PASSWORD \
|
||||||
--set "aws_access_key_id=$AWS_ACCESS_KEY_ID" \
|
--set "aws_access_key_id=$AWS_ACCESS_KEY_ID" \
|
||||||
|
|||||||
@@ -15,6 +15,35 @@ POSTGRES_PORT="${POSTGRES_PORT:-5432}"
|
|||||||
POSTGRES_SSL_MODE=${POSTGRES_SSL_MODE:-"require"}
|
POSTGRES_SSL_MODE=${POSTGRES_SSL_MODE:-"require"}
|
||||||
RESTIC_TAG=${RESTIC_TAG:-"pg_basebackup"}
|
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
|
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 --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"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
image:
|
image:
|
||||||
repository: git.mak-sim.ru/maksim/pg_backup
|
repository: git.mak-sim.ru/maksim/pg_backup
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
tag: "0.0.6"
|
tag: "0.0.7"
|
||||||
|
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
|
|||||||
Reference in New Issue
Block a user