Moved cron tasks to another stack.
This commit is contained in:
parent
7bb19533d8
commit
e852b0b2c2
1
README
1
README
@ -13,5 +13,4 @@ chcon -Rt svirt_sandbox_file_t /var/lib/docker-latest/volumes/mysql-server_dumps
|
||||
Utilisation :
|
||||
|
||||
Les droits des fichiers doivent être corrigés avant de lancer la stack avec docker-compose up -d :
|
||||
chcon -u system_u -r object_r -t svirt_sandbox_file_t crontab
|
||||
chcon -u system_u -r object_r -t svirt_sandbox_file_t nettoyer_quotas.sh
|
||||
|
@ -1,13 +0,0 @@
|
||||
# /etc/crontab: system-wide crontab
|
||||
# Unlike any other crontab you don't have to run the `crontab'
|
||||
# command to install the new version when you edit this file
|
||||
# and files in /etc/cron.d. These files also have username fields,
|
||||
# that none of the other crontabs do.
|
||||
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
# m | h | day of month | month | day of week | user | command
|
||||
3 0 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server /root/nettoyer_quotas.sh > /proc/1/fd/2 2>&1
|
||||
3 1 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases mysql -uroot -pXXXXXXXX > /mnt/dumps/mysql_dump-mysql_`date +\%d-\%m-\%Y`" > /proc/1/fd/2 2>&1
|
||||
13 1 * * * root docker -H tcp://127.0.0.1:2375 exec mysql-server sh -c "mysqldump --databases gogs owncloud semanticscuttle -uroot -pXXXXXXXX > /mnt/dumps/mysql_dump_`date +\%d-\%m-\%Y`" > /proc/1/fd/2 2>&1
|
@ -15,14 +15,6 @@ services:
|
||||
- ./nettoyer_quotas.sh:/root/nettoyer_quotas.sh:Z
|
||||
- ./debian.cnf:/etc/mysql/debian.cnf:Z
|
||||
|
||||
cron:
|
||||
image: cron:$VERSION_CRON
|
||||
#build: "https://git.scimetis.net/yohan/docker-cron.git"
|
||||
restart: always
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- ./crontab:/etc/crontab:Z
|
||||
|
||||
networks:
|
||||
|
||||
mysqlnet:
|
||||
|
@ -2,15 +2,15 @@
|
||||
test -z $1 || HOST="_$1"
|
||||
test -z $2 || INSTANCE="_$2"
|
||||
test -f ~/secrets.tar.gz.enc || { echo "ERROR: ~/secrets.tar.gz.enc not found, exiting."; exit 1; }
|
||||
openssl enc -aes-256-cbc -d -in ~/secrets.tar.gz.enc | tar -zxv --strip 2 secrets/docker-mysql-stack${HOST}${INSTANCE}/crontab secrets/docker-mysql-stack${HOST}${INSTANCE}/debian.cnf
|
||||
sudo chown root. crontab debian.cnf
|
||||
sudo chmod 644 crontab
|
||||
openssl enc -aes-256-cbc -d -in ~/secrets.tar.gz.enc | tar -zxv --strip 2 secrets/docker-mysql-stack${HOST}${INSTANCE}/debian.cnf
|
||||
sudo chown root. debian.cnf
|
||||
|
||||
test -f ~/openrc.sh || { echo "ERROR: ~/openrc.sh not found, exiting."; exit 1; }
|
||||
source ~/openrc.sh
|
||||
INSTANCE=$(/home/yohan/env_py3/bin/openstack server show -c id --format value $(hostname))
|
||||
for VOLUME in mysql-server_data mysql-server_dumps
|
||||
do
|
||||
mkdir -p /mnt/volumes/${VOLUME}
|
||||
if ! mountpoint -q /mnt/volumes/${VOLUME}
|
||||
then
|
||||
VOLUME_ID=$(/home/yohan/env_py3/bin/openstack volume show ${VOLUME} -c id --format value)
|
||||
@ -29,7 +29,7 @@ sudo docker image inspect duplicity:latest &> /dev/null ||{ echo "ERROR: duplici
|
||||
|
||||
rm -rf ~/build
|
||||
mkdir -p ~/build
|
||||
for name in docker-cron docker-mysql
|
||||
for name in docker-mysql
|
||||
do
|
||||
sudo -E docker run --rm -e SWIFT_USERNAME=$OS_USERNAME \
|
||||
-e SWIFT_PASSWORD=$OS_PASSWORD \
|
||||
@ -43,16 +43,14 @@ do
|
||||
tar -xzf ~/build/${name}.tar.gz -C ~/build/
|
||||
done
|
||||
|
||||
unset VERSION_MYSQL VERSION_CRON
|
||||
unset VERSION_MYSQL
|
||||
DIRECTORY=$(pwd)
|
||||
cd ~/build/docker-mysql; export VERSION_MYSQL=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY
|
||||
cd ~/build/docker-cron; export VERSION_CRON=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY
|
||||
|
||||
sudo docker build -t mysql-server:$VERSION_MYSQL ~/build/docker-mysql
|
||||
sudo docker build -t cron:$VERSION_CRON ~/build/docker-cron
|
||||
|
||||
sudo -E bash -c 'docker-compose up -d --force-recreate'
|
||||
# --force-recreate is used to recreate container when crontab file has changed
|
||||
# --force-recreate is used to recreate container when a file has changed
|
||||
# We cannot remove the secrets files or restarting the container would become impossible
|
||||
# rm -f crontab debian.cnf
|
||||
# rm -f debian.cnf
|
||||
rm -rf ~/build
|
||||
|
Loading…
Reference in New Issue
Block a user