[ADD]Odoo backup template : integrate ALT method for dumps
This commit is contained in:
parent
5bc65957aa
commit
da77788e9a
@ -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}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user