I've duplicated a site using the following code. All code worked fine until the last row (the site itself goes up on the web but the last row of code fails and I get an error):
echo "Please enter the domain of the site for duplication"
read domain
echo "Please enter the password of the site's DB user"
read -s psw
cp -r /var/www/html/${domain} /var/www/html/test
sed -i "s/${domain}/test"/g /var/www/html/test/wp-config.php
mysql -u root -p <<-MYSQL
DROP user IF EXISTS 'test'@'localhost'; SELECT user FROM mysql.user;
DROP database IF EXISTS test; show databases;
CREATE user 'test'@'localhost' IDENTIFIED BY '${psw}';
CREATE database test;
GRANT ALL PRIVILEGES ON test.* TO test@localhost;
MYSQL
cd /var/www/html/test
wp search-replace "${domain}" "test" --allow-root
The last WPCLI command outputs:
Error: The site you have requested is not installed.
The same goes for other WPCLI commands. For some reason, WPCLI doesn't recognize my test
site.
Any idea why WPCLI doesn't recognize my site when I'm clearly inside its directory?
Update for motivast:
mysql -u root -p <<-MYSQL
DROP user IF EXISTS 'test'@'localhost'; SELECT user FROM mysql.user;
DROP database IF EXISTS test; show databases;
CREATE user 'test'@'localhost' IDENTIFIED BY '${psw}';
CREATE database test;
GRANT ALL PRIVILEGES ON test.* TO test@localhost;
MYSQL
mysqldump -u root -p ${domain} > test.sql
mysql -u root -p test < test.sql
Did I have the logic right? Did I passed the test?