diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 0d00767c..f9bd1c9d 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,38 +7,43 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CONFIG=wp-config.php + elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + EE_SITE_CONFIG=ee-config.php + fi + # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" else EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" else EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" else EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi fi eval $EE_MIGRATE_CMD1 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - eval $EE_MIGRATE_CMD2 \ - || ee_lib_error "Unable to migrate data using rsync, exit status = " $? + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ]; then + eval $EE_MIGRATE_CMD2 &>> $EE_COMMAND_LOG fi } diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 4727d205..36911ec8 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -7,7 +7,7 @@ function ee_mod_migrate_setup() cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? - # Setup Database + # Setup Database for WordPress site if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ @@ -28,6 +28,21 @@ function ee_mod_migrate_setup() fi fi + # Setup database for MySQL site + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + if [ -f /var/www/$EE_DOMAIN/htdocs/ee-config.php ]; then + rm /var/www/$EE_DOMAIN/htdocs/ee-config.php + fi + if [ "$EE_MYSQL_PATH" != "" ]; then + + EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/ee-config.php | cut -d"'" -f4) + # Import database + ee_lib_echo "Importing database, please wait..." + pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ + || ee_lib_error "Unable to import database, exit status = " $? + fi + fi + # Fix webroot permission chown -R www-data:www-data /var/www/$EE_DOMAIN/ \ || ee_lib_error "Unable to change webroot permission, exit status = " $?