From da77788e9a4e081e3bc2bfe9d07a128aeb13bfab Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Thu, 30 May 2019 20:21:20 +0200 Subject: [PATCH] [ADD]Odoo backup template : integrate ALT method for dumps --- odoo/backups/backup.template | 2 +- odoo/backups/launch.sh | 4 +++- odoo/scripts/backup.py | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/odoo/backups/backup.template b/odoo/backups/backup.template index ff5c69e..207a548 100644 --- a/odoo/backups/backup.template +++ b/odoo/backups/backup.template @@ -1 +1 @@ -python backup.py -oh ${HOST} -pw ${ADMIN_PASSWORD} -f ${FMT} -D backups/ -n ${DATABASES} +python backup.py -oh ${HOST} -pw ${ADMIN_PASSWORD} -f ${FMT} -alt ${ALT} -D backups/ -n ${DATABASES} diff --git a/odoo/backups/launch.sh b/odoo/backups/launch.sh index 40630f1..f1f964e 100644 --- a/odoo/backups/launch.sh +++ b/odoo/backups/launch.sh @@ -7,13 +7,15 @@ IFS=':' read -ra ODOO_HOST <<< "$ODOO_HOST" IFS=':' read -ra ODOO_ADMIN_PASSWORD <<< "$ODOO_ADMIN_PASSWORD" IFS=':' read -ra ODOO_DATABASES <<< "$ODOO_DATABASES" IFS=':' read -ra ODOO_FMT <<< "$ODOO_FMT" +IFS=':' read -ra ODOO_ALT <<< "$ODOO_ALT" for host in "${ODOO_HOST[@]}" do HOST=${host} ADMIN_PASSWORD=${ODOO_ADMIN_PASSWORD[$index]} DATABASES=${ODOO_DATABASES[$index]} FMT=${ODOO_FMT[$index]:='zip'} - export HOST ADMIN_PASSWORD DATABASES FMT + ALT=${ODOO_ALT[$index]:='no'} + export HOST ADMIN_PASSWORD DATABASES FMT ALT envsubst < /home/odoo/backup.template >> /home/odoo/backup.sh ((index++)) done diff --git a/odoo/scripts/backup.py b/odoo/scripts/backup.py index 89b26f7..7d14ffe 100644 --- a/odoo/scripts/backup.py +++ b/odoo/scripts/backup.py @@ -18,7 +18,7 @@ def datefmt(): def dump(odoo, args): """ Dumps a database list from API or HTTP call """ for dbname in args.names.split(','): - if not args.alternative: + if args.alternative == 'no': dumpf = odoo.db.dump(args.password, dbname, args.format) else: conn = httplib.HTTPConnection(args.host, args.port) @@ -41,7 +41,7 @@ def dump(odoo, args): ) with open(fpath, 'wb') as zipf: zipf.write(dumpf.read()) - if args.alternative: + if args.alternative != 'no': conn.close() return True @@ -57,8 +57,8 @@ def main(): help='optional database names (default:all)') parser.add_argument('-f', '--format', type=str, default='zip', help='optional database format (default:zip)') - parser.add_argument('-alt', '--alternative', type=bool, default=False, - help='alternative dump through HTTP POST') + parser.add_argument('-alt', '--alternative', type=str, default='no', + help='alternative dump through HTTP calls (default:no)') args = parser.parse_args() # Connection