This post describes how to duplicate Wordpress site. For example, duplicate the site http://localhost/wordpress to http://localhost/wordpress_backup. Two sites have separate database.

Copy website and grant permission:

cp -r /var/www/html/wordpress /var/www/html/wordpress_backup
cd /var/www/html/wordpress_backup
sudo chown -R root:www-data *
mkdir wp-content/uploads
sudo chown -R :www-data wp-content/uploads
chmod -R 777 wp-content/

Create a new empty database:

mysql -u root -p
CREATE DATABASE wordpress_backup;
exit

Export target MySQL database and clone to the new database:

mysqldump -u root -p wordpress > wordpress_backup.sql
mysql -u root -p wordpress_backup < wordpress_backup.sql

Check the new database:

mysql -u root -p
SHOW TABLES FROM wordpress_backup;

Update the database in wp-config.php file:

define('WP_HOME','http://localhost/wordpress_backup');
define('wordpressURL','http://localhost/wordpress_backup');
define('DB_NAME', 'wordpress_backup');

Update the apache config file /etc/apache2/apache2.conf:

<Directory /var/www/html/agro2019/>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Restart Apache:

service apache2 restart