diff --git a/odoo/backups/backup.template b/odoo/backups/backup.template index cb50bc7..a6e6001 100644 --- a/odoo/backups/backup.template +++ b/odoo/backups/backup.template @@ -1,3 +1 @@ -#!/bin/bash - -python backup.py -oh ${ODOO_HOST} -pw ${ODOO_ADMIN_PASSWORD} -D backups/ -n ${ODOO_DATABASES} +python backup.py -oh ${HOST} -pw ${ADMIN_PASSWORD} -D backups/ -n ${DATABASES} diff --git a/odoo/backups/launch.sh b/odoo/backups/launch.sh index 8fc147f..c801c74 100644 --- a/odoo/backups/launch.sh +++ b/odoo/backups/launch.sh @@ -1,5 +1,19 @@ #!/bin/bash -envsubst < /home/odoo/backup.template > /home/odoo/backup.sh +set -f +echo '#!/bin/bash' > /home/odoo/backup.sh +index=0 +ODOO_HOST=(${ODOO_HOST//:/ }) +ODOO_ADMIN_PASSWORD=(${ODOO_ADMIN_PASSWORD//:/ }) +ODOO_DATABASES=(${ODOO_DATABASES//:/ }) +for host in "${ODOO_HOST[@]}" +do + HOST=${host} + ADMIN_PASSWORD=${ODOO_ADMIN_PASSWORD[$index]} + DATABASE=${ODOO_DATABASES[$index]} + export HOST ADMIN_PASSWORD DATABASES + envsubst < /home/odoo/backup.template >> /home/odoo/backup.sh + ((index++)) +done chown odoo:odoo /home/odoo/backup.sh crontab ./crontab && touch /var/log/cron.log && cron && tail -f /var/log/cron.log