User Tools

Site Tools


backup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

backup [2019/01/29 12:35] (current)
pi created
Line 1: Line 1:
 +<​code>​
 +#!/bin/bash
  
 +# vars
 +BACKUP_DIR=/​opt/​backups
 +ODOO_DATABASE=Production
 +BACKUP_FILE=${ODOO_DATABASE}.$(date +%F-%H%M).zip
 +ADMIN_PASSWORD=moMenulIslam123#​
 +S3_BUCKET_URL=s3://​buetcontent
 +ODOO_LOG_DIR=/​opt/​logs
 +APACHE_LOG_DIR=/​var/​log/​apache2
 +
 +# create a backup directory
 +mkdir -p ${BACKUP_DIR}
 +
 +# create a backup
 +curl -X POST \
 +    -F "​master_pwd=${ADMIN_PASSWORD}"​ \
 +    -F "​name=${ODOO_DATABASE}"​ \
 +    -F "​backup_format=zip"​ \
 +    -o ${BACKUP_DIR}/​${BACKUP_FILE} \
 +    http://​localhost/​web/​database/​backup
 +
 +# copy backup + logs to aws s3
 +aws s3 sync ${BACKUP_DIR} ${S3_BUCKET_URL}/​backups/​database --delete
 +aws s3 sync ${APACHE_LOG_DIR} ${S3_BUCKET_URL}/​logs/​apache --delete
 +aws s3 sync ${ODOO_LOG_DIR} ${S3_BUCKET_URL}/​logs/​odoo --delete
 +
 +# delete old backups
 +find ${BACKUP_DIR} -type f -mtime +7 -name "​${ODOO_DATABASE}.*.zip"​ -delete
 +</​code>​
backup.txt ยท Last modified: 2019/01/29 12:35 by pi