Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier / faster way or bad idea? #18

Open
erus00 opened this issue Jul 21, 2020 · 0 comments
Open

Easier / faster way or bad idea? #18

erus00 opened this issue Jul 21, 2020 · 0 comments

Comments

@erus00
Copy link

erus00 commented Jul 21, 2020

Hi,

What would you think of a simple script like this one?
Wouldn't it be easier or am I being too simplistic using sed?

$SITE_B_DB, $SITE_B_USER, PREFIX1, PREFIX2, SITE_B would need to be replaced in the script.

wp --allow-root db export /tmp/export1.sql # Export DB
sudo sed "s/$PREFIX1/PREFIX2/g" /tmp/export1.sql > export2.sql # Replace prefix (make sure it is random like "ds5K6g" so no issue with DB content)

mysql -u root -p'"$var_mysql_password"' -e \"DROP DATABASE $SITE_B_DB; 
mysql -u root -p'"$var_mysql_password"' -e \"CREATE DATABASE $SITE_B_DB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql -u root -p'"$var_mysql_password"' -e \"GRANT ALL ON $SITE_B_DB.* TO '$SITE_B_USER'@'localhost';
mysql -u root -p'"$var_mysql_password"' -e \"FLUSH PRIVILEGES;

wp --allow-root db import /tmp/export2.sql # Import of the DB

sudo sed -i "s/$PREFIX1/$PREFIX2/g" $SITE_B/wp-config.php #Replace the DB name is wp-config

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant