diff --git a/bin/easyengine b/bin/easyengine index b5febbf0..322dfffb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -605,10 +605,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - mv $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//')/{ee-config.php,backup/db/ee-config-$(date +"%m-%d-%y::%T").php.bak} &>> $EE_COMMAND_LOG + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) fi ee_mod_setup_wordpress fi diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 89a17394..cac25593 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -15,6 +15,9 @@ readonly EE_ROUNDCUBE_VERSION='1.0.3' # ViMbAdmin Version readonly EE_VIMBADMIN_VERSION='3.0.10' +# EasyEngine Date variable for backup +readonly EE_DATE=$(date +%d%b%Y%H%M%S) + EE_COMMAND_LOG=/var/log/easyengine/ee.log readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f763fa73..21b55f2f 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -11,18 +11,21 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then ee_lib_echo "Creating Webroot backup for $EE_DOMAIN before updating ..." - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y::%T") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN before updating ..." # Backup $EE_DOMAIN NGINX configuration - cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y::%T").conf.bak &>> $EE_COMMAND_LOG + cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +%d%b%Y%H%M%S).conf.bak &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y::%T").sql.bak &>> $EE_COMMAND_LOG + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +%d%b%Y%H%M%S).sql.bak &>> $EE_COMMAND_LOG + + # Move ee-config.php and wp-config.php + mv $ee_webroot/*-config.php $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/*-config.php to backup, exit status =" $? fi }