Commit b8ba2cf8 authored by Sandeep Kadam's avatar Sandeep Kadam
Browse files

Updated dump process to work with global var & local env

parent 25f07e99
......@@ -30,14 +30,38 @@ case "${ENVIRONMENT}" in
*) usage ;;
esac;
# Logic to check if script running on gitlab or local, so we can update server.
isxclient=$( readlink /dev/fd/2 | grep -q 'tty' && [[ -n $DISPLAY ]] ; echo $? )
if [[ ! -t 2 || $isxclient == "0" ]]; then
echo "Script wasn't started from an interactive shell"
LOCAL_DEPLOYMENT=0;
else
echo "Script was started from an interactive shell"
LOCAL_DEPLOYMENT=1;
fi
EBI_CLI_SERVER="${SSH_APACHE}@ebi-cli";
NFS_MYSQL_BACKUP_PATH="/nfs/public/rw/webdevel/projects/drupal/mysql-backups";
case "${COMMAND}" in
sql)
rm -rf ${RELATIVE_SQLDUMP_SRC} ${RELATIVE_SQLDATA_SRC};
mkdir -pv ${RELATIVE_SQLDUMP_SRC};
SQLDUMP_FILE=${RELATIVE_SQLDUMP_SRC}/${ENVIRONMENT}.${DEPLOY_INSTANCE}.${PROJECT_NAME}.sql.gz;
PROJECT_FOLDER_PATH="$NFS_MYSQL_BACKUP_PATH/${ENVIRONMENT}_${DEPLOY_INSTANCE}_${PROJECT_NAME//./_}";
echo "Dumping database from ${ENVIRONMENT}.${DEPLOY_INSTANCE}.${PROJECT_NAME}...";
ssh -tt ${SSH_OWNER}@${REMOTE_HOST} "cd ${VM_CORE_PATH}; vendor/bin/drush sql-dump" | gzip > ${SQLDUMP_FILE};
if [ "$LOCAL_DEPLOYMENT" -eq "1" ] ; then
echo "Coming in Local CLI dump";
# Download the last backup file from mysql backups location.
scp $EBI_CLI_SERVER:$(ssh $EBI_CLI_SERVER "ls -t $PROJECT_FOLDER_PATH/* | head -1") ${SQLDUMP_FILE};
else
echo "Coming in deployment server dump";
ssh -tt ${SSH_OWNER}@${REMOTE_HOST} "cd ${VM_CORE_PATH}; vendor/bin/drush sql-dump" | gzip > ${SQLDUMP_FILE};
fi
echo "Database dumped to ${SQLDUMP_FILE}";
;;
......@@ -46,10 +70,18 @@ case "${COMMAND}" in
mkdir -pv ${RELATIVE_FILES_SRC} ${RELATIVE_PRIVATE_SRC};
echo "Dumping files from ${ENVIRONMENT}.${DEPLOY_INSTANCE}.${PROJECT_NAME}...";
rsync -auv --delete --ignore-errors \
if [ "$LOCAL_DEPLOYMENT" -eq "1" ] ; then
rsync -auv --delete --ignore-errors \
$EBI_CLI_SERVER:${NFS_FILES_SRC}/. ${RELATIVE_FILES_SRC}/;
rsync -auv --delete --ignore-errors \
$EBI_CLI_SERVER:${NFS_PRIVATE_SRC}/. ${RELATIVE_PRIVATE_SRC}/;
else
rsync -auv --delete --ignore-errors \
${SSH_APACHE}@${REMOTE_HOST}:${VM_CORE_PATH}/${RELATIVE_FILES_SRC}/. ${RELATIVE_FILES_SRC}/;
rsync -auv --delete --ignore-errors \
rsync -auv --delete --ignore-errors \
${SSH_APACHE}@${REMOTE_HOST}:${VM_CORE_PATH}/${RELATIVE_PRIVATE_SRC}/. ${RELATIVE_PRIVATE_SRC}/;
fi
echo "Files dumped to ${RELATIVE_FILES_SRC} and ${RELATIVE_PRIVATE_SRC}";
;;
......@@ -58,7 +90,32 @@ case "${COMMAND}" in
mkdir -pv ${RELATIVE_FILES_SRC} ${RELATIVE_PRIVATE_SRC};
echo "Dumping essential files from ${ENVIRONMENT}.${DEPLOY_INSTANCE}.${PROJECT_NAME}...";
rsync -auv --delete --ignore-errors \
if [ "$LOCAL_DEPLOYMENT" -eq "1" ] ; then
rsync -auv --delete --ignore-errors \
--exclude=styles \
--exclude=*.old \
--exclude=*.bak \
--exclude=*.pdf \
--exclude=*.tar* \
--exclude=*.zip \
--exclude=*.doc* \
--exclude=*.ppt* \
--exclude=*.xls* \
$EBI_CLI_SERVER:${NFS_FILES_SRC}/. ${RELATIVE_FILES_SRC}/;
rsync -auv --delete --ignore-errors \
--exclude=styles \
--exclude=*.old \
--exclude=*.bak \
--exclude=*.pdf \
--exclude=*.tar* \
--exclude=*.zip \
--exclude=*.doc* \
--exclude=*.ppt* \
--exclude=*.xls* \
$EBI_CLI_SERVER:${NFS_PRIVATE_SRC}/. ${RELATIVE_PRIVATE_SRC}/;
else
rsync -auv --delete --ignore-errors \
--exclude=styles \
--exclude=*.old \
--exclude=*.bak \
......@@ -69,7 +126,7 @@ case "${COMMAND}" in
--exclude=*.ppt* \
--exclude=*.xls* \
${SSH_APACHE}@${REMOTE_HOST}:${VM_CORE_PATH}/${RELATIVE_FILES_SRC}/. ${RELATIVE_FILES_SRC}/;
rsync -auv --delete --ignore-errors \
rsync -auv --delete --ignore-errors \
--exclude=styles \
--exclude=*.old \
--exclude=*.bak \
......@@ -80,6 +137,9 @@ case "${COMMAND}" in
--exclude=*.ppt* \
--exclude=*.xls* \
${SSH_APACHE}@${REMOTE_HOST}:${VM_CORE_PATH}/${RELATIVE_PRIVATE_SRC}/. ${RELATIVE_PRIVATE_SRC}/;
fi
echo "Files dumped to ${RELATIVE_FILES_SRC} and ${RELATIVE_PRIVATE_SRC}";
;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment