Last active
March 11, 2020 05:05
-
-
Save quangthe/5dbb9f0d6547c593ec9b1d63e1942948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Require environment variable: | |
# AWS_ACCESS_KEY_ID | |
# AWS_SECRET_ACCESS_KEY | |
set -e | |
BUCKET=dt-odoo-backup | |
echo "Get latest db backup" | |
aws s3 ls $BUCKET --recursive | grep \.*sql | sort | tail -n 1 | awk '{print $4}' | while read -r line; do | |
echo "Downloading from s3://$BUCKET/$line..." | |
aws s3 cp s3://$BUCKET/$line $line | |
echo "Restore DB into DB docker" | |
cat $line | docker exec -i odoodb psql -U postgres | |
done | |
echo "Get latest odoo files" | |
aws s3 ls $BUCKET --recursive | grep \.*zip | sort | tail -n 1 | awk '{print $4}' | while read -r line; do | |
echo "Downloading from s3://$BUCKET/$line..." | |
aws s3 cp s3://$BUCKET/$line $line | |
echo "Restore ODOO files into ~/odoo" | |
echo "Extracting data to odoo files destination" | |
unzip -o $line -d ~/odoo/ | |
sudo chmod -R 777 ~/odoo | |
cat $(find ~/odoo -name "*.sql") | docker exec -i odoodb psql -U postgres | |
echo "Done" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment