[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_ADMIN_PASSWORD <<< "$ODOO_ADMIN_PASSWORD"
|
||||||
IFS=':' read -ra ODOO_DATABASES <<< "$ODOO_DATABASES"
|
IFS=':' read -ra ODOO_DATABASES <<< "$ODOO_DATABASES"
|
||||||
IFS=':' read -ra ODOO_FMT <<< "$ODOO_FMT"
|
IFS=':' read -ra ODOO_FMT <<< "$ODOO_FMT"
|
||||||
|
IFS=':' read -ra ODOO_ALT <<< "$ODOO_ALT"
|
||||||
for host in "${ODOO_HOST[@]}"
|
for host in "${ODOO_HOST[@]}"
|
||||||
do
|
do
|
||||||
HOST=${host}
|
HOST=${host}
|
||||||
ADMIN_PASSWORD=${ODOO_ADMIN_PASSWORD[$index]}
|
ADMIN_PASSWORD=${ODOO_ADMIN_PASSWORD[$index]}
|
||||||
DATABASES=${ODOO_DATABASES[$index]}
|
DATABASES=${ODOO_DATABASES[$index]}
|
||||||
FMT=${ODOO_FMT[$index]:='zip'}
|
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
|
envsubst < /home/odoo/backup.template >> /home/odoo/backup.sh
|
||||||
((index++))
|
((index++))
|
||||||
done
|
done
|
||||||
|
@ -18,7 +18,7 @@ def datefmt():
|
|||||||
def dump(odoo, args):
|
def dump(odoo, args):
|
||||||
""" Dumps a database list from API or HTTP call """
|
""" Dumps a database list from API or HTTP call """
|
||||||
for dbname in args.names.split(','):
|
for dbname in args.names.split(','):
|
||||||
if not args.alternative:
|
if args.alternative == 'no':
|
||||||
dumpf = odoo.db.dump(args.password, dbname, args.format)
|
dumpf = odoo.db.dump(args.password, dbname, args.format)
|
||||||
else:
|
else:
|
||||||
conn = httplib.HTTPConnection(args.host, args.port)
|
conn = httplib.HTTPConnection(args.host, args.port)
|
||||||
@ -41,7 +41,7 @@ def dump(odoo, args):
|
|||||||
)
|
)
|
||||||
with open(fpath, 'wb') as zipf:
|
with open(fpath, 'wb') as zipf:
|
||||||
zipf.write(dumpf.read())
|
zipf.write(dumpf.read())
|
||||||
if args.alternative:
|
if args.alternative != 'no':
|
||||||
conn.close()
|
conn.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ def main():
|
|||||||
help='optional database names (default:all)')
|
help='optional database names (default:all)')
|
||||||
parser.add_argument('-f', '--format', type=str, default='zip',
|
parser.add_argument('-f', '--format', type=str, default='zip',
|
||||||
help='optional database format (default:zip)')
|
help='optional database format (default:zip)')
|
||||||
parser.add_argument('-alt', '--alternative', type=bool, default=False,
|
parser.add_argument('-alt', '--alternative', type=str, default='no',
|
||||||
help='alternative dump through HTTP POST')
|
help='alternative dump through HTTP calls (default:no)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Connection
|
# Connection
|
||||||
|
Loading…
Reference in New Issue
Block a user