Last active
October 18, 2016 21:04
-
-
Save gwillem/0a5894ac44ba82cd9d7b to your computer and use it in GitHub Desktop.
Create Hypernode copy of live site
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
# is there enough space? | |
DBNAME=$(magerun --root-dir=~/public db:info dbname) | |
USAGE_FILE=$(( ( $(du -s --exclude=public/media/\* ~/public | cut -f1) - $(du -s --exclude=public/media/\* ~/staging | cut -f1) ) / 1024 )) | |
USAGE_DB=$(( $(du -s --exclude= /data/mysql/$DBNAME | cut -f1) / 1024 )) | |
FREE_SPACE_PRE=$(( $(stat -f --format='%a*%S/1024' ~/public) / 1024 )) | |
FREE_SPACE_POST=$(( $FREE_SPACE_PRE - $USAGE_FILE - $USAGE_DB )) | |
# Todo: which db tables to exclude? these: magerun db:dump --stdout --only-command --strip="@stripped" | sed -e 's/ /\n/g' | grep ignore-table | cut -d. -f2 | |
echo "Free $FREE_SPACE_PRE MB, file usage $USAGE_FILE MB, db usage $USAGE_DB MB" | |
echo "Free space after clone will be $FREE_SPACE_POST MB" | |
if (( $FREE_SPACE_POST > 500 )); then | |
echo "Free space after copy ($FREE_SPACE_POST) is more than 500 MB, continuing..."; | |
else | |
echo "Free space after copy ($FREE_SPACE_POST) would be less than minimum so aborting"; | |
exit 1; | |
fi | |
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
SHOPHOST=shop.byte.nl | |
rsync -va --delete --delete-excluded \ | |
--exclude /media \ | |
--exclude /var/report/ \ | |
--exclude /var/session/ \ | |
--exclude /var/log/ \ | |
--exclude \*.sql \ | |
--exclude \*.zip \ | |
~/public/ ~/staging/ | |
# Make hardlinks so don't use up space | |
cp -fvlr ~/public/media ~/staging/ | |
mysql -e 'create database if not exists staging' | |
cd ~/public | |
magerun --root-dir=~/public db:dump --strip="@stripped" --stdout | mysql staging | |
# update local.xml & fpc.xml with new db name ("staging") and other redis db (ie nr 4) | |
nano ~/staging/app/etc/local.xml | |
test -e ~/staging/app/etc/fpc.xml && nano ~/staging/app/etc/fpc.xml | |
cd ~/staging | |
magerun --root-dir=~/staging config:set web/unsecure/base_url http://$SHOPHOST:10080/ | |
magerun --root-dir=~/staging config:set web/secure/base_url https://$SHOPHOST:10443/ | |
magerun cache:flush |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great scripts.
Just a little question. Is it intended to change the base_urls of the production website when running the clone-hypernode-to-staging.sh script? When I run the script my production environment is changed.