[IMP]Odoo backup image can now be used for 1 or many hosts

This commit is contained in:
Fabien BOURGEOIS 2018-02-17 16:21:05 +01:00
parent f6a1a9e5c7
commit cb91dda76a
2 changed files with 16 additions and 4 deletions

View File

@ -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}

View File

@ -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