Verified Commit 036f4267 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

[DBBackup] Fix weekpad db, rebuild image for PG12 and cron to 3AM

parent d78b4755
Pipeline #62754 failed with stages
in 55 seconds
## Version 1.3
* Update for PG12+
* Default cron hour at 03:00AM
......@@ -3,7 +3,7 @@ FROM python:3-slim-buster
RUN apt-get update && \
apt-get install -y --no-install-recommends \
iputils-ping \
postgresql-client \
postgresql-client-12 \
default-mysql-client \
mongo-tools \
cron && \
......@@ -15,7 +15,7 @@ COPY mysql-run.sh /scripts/mysql/mysql-run.sh
COPY postgres-run.sh /scripts/postgresql/postgres-run.sh
COPY mongo-run.sh /scripts/mongodb/mongo-run.sh
ENV CRON_TIME="0 0 * * *"
ENV CRON_TIME="0 3 * * *"
VOLUME ["/backup"]
......
......@@ -6,17 +6,17 @@ import json
# Take a variable and set it as environment variable
def add_value_to_key(value, key):
if "MONGO" in key:
if(flag_mongo):
if flag_mongo:
os.environ[key] = os.environ[key] + "," + value
else:
os.environ[key] = value
if "MYSQL" in key:
if(flag_mysql):
if flag_mysql:
os.environ[key] = os.environ[key] + "," + value
else:
os.environ[key] = value
if "POSTGRES" in key:
if(flag_postgres):
if flag_postgres:
os.environ[key] = os.environ[key] + "," + value
else:
os.environ[key] = value
......@@ -24,7 +24,7 @@ def add_value_to_key(value, key):
CONFIG_FILE = '/config/backup_config.json'
# Check if config file exists
if not(os.path.isfile(CONFIG_FILE)):
if not os.path.isfile(CONFIG_FILE):
sys.stderr.write("Error : {0} config file not found".format(CONFIG_FILE))
sys.exit()
......@@ -39,58 +39,56 @@ for service in services_list:
if services_list[service]["Type"] == "mongo":
# Mongo DB handling
add_value_to_key(service,"MONGO_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"],"MONGO_HOST_LIST")
add_value_to_key(services_list[service]["Port"],"MONGO_PORT_LIST")
add_value_to_key(services_list[service]["Database"],"MONGO_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"],"MONGO_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"],"MONGO_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"],"MONGO_BACKUP_FOLDER_LIST")
add_value_to_key(service, "MONGO_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"], "MONGO_HOST_LIST")
add_value_to_key(services_list[service]["Port"], "MONGO_PORT_LIST")
add_value_to_key(services_list[service]["Database"], "MONGO_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"], "MONGO_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"], "MONGO_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"], "MONGO_BACKUP_FOLDER_LIST")
flag_mongo = True
if services_list[service]["Type"] == "mysql":
# MySQL DB handling
add_value_to_key(service,"MYSQL_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"],"MYSQL_HOST_LIST")
add_value_to_key(services_list[service]["Port"],"MYSQL_PORT_LIST")
add_value_to_key(service, "MYSQL_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"], "MYSQL_HOST_LIST")
add_value_to_key(services_list[service]["Port"], "MYSQL_PORT_LIST")
user = services_list[service]["User"]
if user in os.environ:
user = os.environ[user]
add_value_to_key(user,"MYSQL_USER_LIST")
add_value_to_key(user, "MYSQL_USER_LIST")
password = services_list[service]["Password"]
if password in os.environ:
password = os.environ[password]
add_value_to_key(password,"MYSQL_PASS_LIST")
add_value_to_key(services_list[service]["Database"],"MYSQL_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"],"MYSQL_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"],"MYSQL_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"],"MYSQL_BACKUP_FOLDER_LIST")
add_value_to_key(services_list[service]["Options"],"MYSQL_EXTRA_OPTS_LIST")
add_value_to_key(password, "MYSQL_PASS_LIST")
add_value_to_key(services_list[service]["Database"], "MYSQL_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"], "MYSQL_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"], "MYSQL_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"], "MYSQL_BACKUP_FOLDER_LIST")
add_value_to_key(services_list[service]["Options"], "MYSQL_EXTRA_OPTS_LIST")
flag_mysql = True
if services_list[service]["Type"] == "postgres":
# PostgreSQL handling
add_value_to_key(service,"POSTGRES_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"],"POSTGRES_HOST_LIST")
add_value_to_key(services_list[service]["Port"],"POSTGRES_PORT_LIST")
add_value_to_key(service, "POSTGRES_SERVICE_NAME_LIST")
add_value_to_key(services_list[service]["Host"], "POSTGRES_HOST_LIST")
add_value_to_key(services_list[service]["Port"], "POSTGRES_PORT_LIST")
user = services_list[service]["User"]
if user in os.environ:
user = os.environ[user]
add_value_to_key(user,"POSTGRES_USER_LIST")
add_value_to_key(user, "POSTGRES_USER_LIST")
password = services_list[service]["Password"]
if password in os.environ:
password = os.environ[password]
add_value_to_key(password,"POSTGRES_PASS_LIST")
add_value_to_key(services_list[service]["Database"],"POSTGRES_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"],"POSTGRES_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"],"POSTGRES_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"],"POSTGRES_BACKUP_FOLDER_LIST")
add_value_to_key(password, "POSTGRES_PASS_LIST")
add_value_to_key(services_list[service]["Database"], "POSTGRES_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"], "POSTGRES_INIT_BACKUP_LIST")
add_value_to_key(services_list[service]["Cron"], "POSTGRES_CRON_TIME_LIST")
add_value_to_key(services_list[service]["Folder"], "POSTGRES_BACKUP_FOLDER_LIST")
flag_postgres = True
# Closing config file
......
......@@ -27,7 +27,7 @@
"Port": "5432",
"User": "ETHERPAD_WEEK_DB_USER",
"Password": "ETHERPAD_WEEK_DB_PASSWORD",
"Database": "--all-databases",
"Database": "weekpad",
"Type": "postgres",
"Folder": "etherpad-week",
"Cron": "0 1 * * *",
......
......@@ -13,7 +13,7 @@ networks:
services:
db-backup:
image: registry.picasoft.net/pica-db-backup:1.2
image: registry.picasoft.net/pica-db-backup:1.3
container_name: db-backup
volumes:
- /DATA/BACKUP/:/backup/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment