-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (44 loc) · 2.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
NETWORK=opstree
ifndef IMAGE_VERSION
override IMAGE_VERSION = 0.1
endif
create-network:
@echo "Creating network ${NETWORK}"
@docker network create ${NETWORK} || true > /dev/null
setup-testdb:
@docker exec testdb psql -h testdb -U postgres opstree -c "CREATE TABLE products (product_no integer, name text, price numeric);"
@docker exec testdb psql -h testdb -U postgres opstree -c "INSERT INTO products (product_no, name, price) VALUES (1, 'Cheese', 9.99);"
@docker exec testdb psql -h testdb -U postgres opstree -c "INSERT INTO products (product_no, name, price) VALUES (2, 'Cheese2', 2.99);"
@docker exec testdb psql -h testdb -U postgres opstree -c "INSERT INTO products (product_no, name, price) VALUES (3, 'Cheese3', 3.99);"
run-testdb:
@docker rm -f testdb || true > /dev/null
@docker run -itd --rm --net ${NETWORK} --name testdb -e PGPASSWORD=password -e POSTGRES_PASSWORD=password -e POSTGRES_DB=opstree postgres:12.4
sleep 5s
make setup-testdb
build:
docker build -t opstree/postgresqlbackup:$(IMAGE_VERSION) .
initStorage:
@docker run -it --net ${NETWORK} -v ${PWD}/sample/properties:/etc/backup -v ${PWD}/sample/backup:/data/backup --rm opstree/postgresqlbackup:$(IMAGE_VERSION) init
listBackups:
@docker run -it --net ${NETWORK} -v ${PWD}/sample/properties:/etc/backup -v ${PWD}/sample/backup:/data/backup --rm opstree/postgresqlbackup:$(IMAGE_VERSION) listBackups
backup:
@docker run -it --net ${NETWORK} -v ${PWD}/sample/properties:/etc/backup -v ${PWD}/sample/backup:/data/backup --rm opstree/postgresqlbackup:$(IMAGE_VERSION) backup
restore:
@docker run -it --net ${NETWORK} -v ${PWD}/sample/properties:/etc/backup -v ${PWD}/sample/backup:/data/backup --rm opstree/postgresqlbackup:$(IMAGE_VERSION) restore $(SNAPSHOT_ID)
run-debug:
docker run -it --net ${NETWORK} -v ${PWD}/sample/properties:/etc/backup -v ${PWD}/sample/backup:/data/backup --rm --entrypoint /bin/bash opstree/postgresqlbackup:$(IMAGE_VERSION)
wait:
@read -p "Press enter to continue...."
clear
end-to-end-test:
make run-testdb
make wait
rm -rf sample/backup
make initStorage
make wait
make backup
make wait
make listBackups
make wait
make restore SNAPSHOT_ID=latest
make wait