-
-
Save hn-support/be909515580cd08bd23a45dc561c3b78 to your computer and use it in GitHub Desktop.
Create Hypernode copy of live site
This file contains 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
#!/bin/bash | |
# This script checks if there is enough diskspace available on your hypernode | |
# to create a basic staging environment as explained in | |
# - https://support.hypernode.com/knowledgebase/using-a-basic-staging-environment-magento1/ | |
# and | |
# - https://support.hypernode.com/knowledgebase/using-a-basic-staging-environment-magento2/ | |
# To use it, download or copy the script and make it executable. | |
# is there enough space? | |
DBNAME=$(magerun --root-dir=~/public db:info dbname) | |
USAGE_FILE=$(( ( $(du -s ~/public | cut -f1) - $(du -s | 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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment