diff --git a/db-backup/backup_env_var.py b/db-backup/backup_env_var.py index 407e4f154a51c29b9ecad948006692388935289b..619c629a9d5c8d769d3da15f16d61db488642a2b 100755 --- a/db-backup/backup_env_var.py +++ b/db-backup/backup_env_var.py @@ -3,7 +3,7 @@ import os import sys import json -#Ajoute la variable correctement dans une variable d'environnement +# Take a variable and set it as environment variable def add_value_to_key(value, key): if "MONGO" in key: if(flag_mongo): @@ -25,7 +25,7 @@ CONFIG_FOLDER = '/config' CONFIG_FILE = 'backup_data.json' PATH_TO_CONFIG = CONFIG_FOLDER + '/' + CONFIG_FILE -#Garde-fou : test d'existence des fichiers et dossiers +# Check if config file exists if not(os.path.exists(CONFIG_FOLDER)): sys.stderr.write('Err: BACKUP_FOLDER or CONFIG_FOLDER doesn\'t exist. \n') sys.exit() @@ -34,7 +34,7 @@ if not(os.path.isfile(PATH_TO_CONFIG)): sys.stderr.write('Err: ' + PATH_TO_CONFIG + ' not found. \n') sys.exit() -#Initialisation des variables +# Variables initialization open_config_file = open(PATH_TO_CONFIG) services_list = json.load(open_config_file) flag_mongo = False @@ -43,7 +43,8 @@ flag_prostgres = False for service in services_list: if services_list[service]["Type"] == "mongo": - #Ajout des clés pour service à DDB 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") @@ -56,7 +57,8 @@ for service in services_list: if services_list[service]["Type"] == "mysql": - #Ajout des clés pour service à DDB 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") @@ -72,7 +74,8 @@ for service in services_list: if services_list[service]["Type"] == "postgres": - #Ajout des clés pour service à DDB Postgre + + # 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") @@ -84,7 +87,7 @@ for service in services_list: add_value_to_key(services_list[service]["Folder"],"POSTGRES_BACKUP_FOLDER_LIST") flag_postgres = True -# Fermeture du fichier de configuration +# Closing config file open_config_file.close() -#Exécution du script run.sh après avoir enregistré toutes les variables du fichier .json dans des variables d'environnement +# Excecution of run.sh after creating all environment variables from .json file os.execv("/scripts/run.sh",[''])