Skip to content

Commit ac4ca0b

Browse files
committed
working version
0 parents  commit ac4ca0b

File tree

27 files changed

+811
-0
lines changed

27 files changed

+811
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/docker/Dockerfile
2+
Makefile
3+
docker-compose*
4+
.git
5+
.gitignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build/docker/*/data
2+
/build/docker/*/*/.walg.json
3+
/build/docker/*/*/config.yml

Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.DEFAULT_GOAL := up
2+
3+
up:
4+
docker compose up -d
5+
6+
down:
7+
docker compose down
8+
9+
build:
10+
docker compose build
11+
12+
exec:
13+
docker compose exec postgres bash
14+
15+
create:
16+
docker compose exec -u postgres postgres wal-g backup-push /var/lib/postgresql/data
17+
18+
all: down up
19+
@make -s create
20+
docker compose logs postgres
21+
22+
test:
23+
go build -o app/main cmd/main.go
24+
docker compose exec -u postgres postgres /app/main --project test --backup_type psql --backup_cron "*/1 * * * *"
25+
26+
tc:
27+
go build -o app/main cmd/main.go
28+
docker compose exec -u postgres postgres /app/main --project test --backup_type psql --config_file /var/lib/postgre
29+
30+
tm:
31+
go build -o app/main cmd/main.go
32+
docker compose exec -u mysql mariadb /app/main --project test --backup_type mariadb --backup_cron "*/1 * * * *"
33+
tmy:
34+
go build -o app/main cmd/main.go
35+
docker compose exec -u mysql mysql /app/main --project test --backup_type mysql --backup_cron "*/1 * * * *"
36+
tmd:
37+
go build -o app/main cmd/main.go
38+
docker compose exec -u mongodb mongo wal-g backup-list
39+
docker compose exec -u mongodb mongo wal-g delete retain FULL 5 --confirm
40+
docker compose exec -u mongodb mongo /app/main --project test --backup_type mongodb --backup_cron "*/1 * * * *"
41+
42+
43+
44+
tch:
45+
go build -o app/main cmd/main.go
46+
docker compose exec -u clickhouse clickhouse /app/main --project test --backup_type clickhouse
47+
48+
49+
.PHONY: up down build exec create all

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Вся логика по созданию бекапа в create.go
2+
3+
# Переменные создаются в config/config.go
4+
5+
# Метрики exporter/collector.go
6+
clickhouse need create table
7+
8+
wal-g psql retein

app/main

11.8 MB
Binary file not shown.

build/docker/clickhouse/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM clickhouse/clickhouse-server:23.10.3.5-alpine
2+
3+
RUN apk add wget \
4+
&& wget https://github.com/AlexAkulov/clickhouse-backup/releases/download/v2.4.5/clickhouse-backup-linux-amd64.tar.gz \
5+
&& tar -xf clickhouse-backup-linux-amd64.tar.gz \
6+
&& cp build/linux/amd64/clickhouse-backup /usr/local/bin/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
general:
2+
remote_storage: s3 # REMOTE_STORAGE, if `none` then `upload` and `download` commands will fail
3+
clickhouse:
4+
username: clickhouse # CLICKHOUSE_USERNAME
5+
password: "password" # CLICKHOUSE_PASSWORD
6+
host: localhost # CLICKHOUSE_HOST, To make backup data `clickhouse-backup` requires access to the same file system as clickhouse-server, so `host` should localhost or address of another docker container on the same machine, or IP address bound to some network interface on the same host.
7+
port: 9000 # CLICKHOUSE_PORT, don't use 8123, clickhouse-backup doesn't support HTTP protocol
8+
s3:
9+
access_key: "access_key" # S3_ACCESS_KEY
10+
secret_key: "secret_key" # S3_SECRET_KEY
11+
bucket: "bucket_name" # S3_BUCKET
12+
endpoint: "https://example.com/" # S3_ENDPOINT
13+
region: eu-central-1 # S3_REGION
14+
acl: private # S3_ACL
15+
assume_role_arn: "" # S3_ASSUME_ROLE_ARN
16+
force_path_style: true # S3_FORCE_PATH_STYLE
17+
path: "bucket_key" # S3_PATH, `system.macros` values can be applied as {macro_name}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE DATABASE IF NOT EXISTS clickhouse;
2+
3+
USE clickhouse;
4+
5+
CREATE TABLE IF NOT EXISTS mytable (
6+
id Int64,
7+
name String
8+
) ENGINE = MergeTree() ORDER BY id;
9+
10+
INSERT INTO mytable (id, name) VALUES (1, 'John'), (2, 'Alice');

build/docker/mariadb/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM mariadb:11.0.4-jammy
2+
3+
RUN apt update \
4+
&& apt install wget vim lsb-release curl mariadb-backup -y \
5+
&& apt --fix-broken install \
6+
&& wget https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-mysql-ubuntu-20.04-amd64.tar.gz \
7+
&& tar -zxvf wal-g-mysql-ubuntu-20.04-amd64.tar.gz \
8+
&& mv wal-g-mysql-ubuntu-20.04-amd64 /usr/local/bin/wal-g
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[client]
2+
user=root
3+
password=password

0 commit comments

Comments
 (0)