This commit is contained in:
commit
8b0467e240
24
.drone.yml
Normal file
24
.drone.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: build and publish
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: ducampsv/docker-consul-backup
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
---
|
||||
kind: secret
|
||||
name: docker_username
|
||||
get:
|
||||
path: secrets/data/droneci/dockerHub
|
||||
name: username
|
||||
---
|
||||
kind: secret
|
||||
name: docker_password
|
||||
get:
|
||||
path: secrets/data/droneci/dockerHub
|
||||
name: password
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM hashicorp/consul:latest
|
||||
ENV CONSUL_HTTP_ADDR="http://consul.service.consul:8500"
|
||||
ENV RETENTION=30
|
||||
ENV TOKEN_AUTH=""
|
||||
COPY cs-backup.sh /
|
||||
CMD ./cs-backup.sh
|
||||
VOLUME /backup
|
13
Readme.md
Normal file
13
Readme.md
Normal file
@ -0,0 +1,13 @@
|
||||
# docker-consul-backup
|
||||
|
||||
perform a backup of consul raft base
|
||||
|
||||
## ENV variable
|
||||
|
||||
- RETENTION
|
||||
- CONSUL_HTTP_ADDR
|
||||
- TOKEN_AUTH
|
||||
|
||||
## mount
|
||||
|
||||
mount your backup location on /backup
|
27
cs-backup.sh
Executable file
27
cs-backup.sh
Executable file
@ -0,0 +1,27 @@
|
||||
export PATH_SNAPSHOT="/backup"
|
||||
export PATH_DIR="daily"
|
||||
export PATH_BACKUP=$PATH_SNAPSHOT"/"$PATH_DIR
|
||||
export RETENTION=30
|
||||
export SNAPSHOT_FILE=$(date +%Y-%m-%d)
|
||||
|
||||
|
||||
create_snapshot_folder(){
|
||||
mkdir -p $PATH_BACKUP
|
||||
}
|
||||
|
||||
run_snapshot() {
|
||||
/bin/consul snapshot save -token=$TOKEN_AUTH $PATH_BACKUP/$SNAPSHOT_FILE.snap
|
||||
}
|
||||
|
||||
retention() {
|
||||
find $PATH_BACKUP -name "*.snap" -mtime +${RETENTION} -print -exec rm {} \;
|
||||
}
|
||||
|
||||
main() {
|
||||
create_snapshot_folder
|
||||
run_snapshot
|
||||
retention
|
||||
}
|
||||
|
||||
### START HERE ###
|
||||
main $@
|
Loading…
Reference in New Issue
Block a user