I want to create a wordpress plugin. The wordpress plugin will be called Clone, Backup & Migrate.
The two main functionnalities of this plugin are the Backup and the Cloning feature.

A backup is constituted of a wordpress custom post of post_type "cbm-backup". This post content contains the full path to a backup archive. A backup archive is containing ta database archive and an archive of the content of the main wordpress folder. A database archive is an archive that contains the archives of each export file of each table that the database of the wordpress website includes.

When restoring a backup, all the table of the database of the wordpress are duplicated by changing their name by adding the same prefix to all of them. Then copy of all the content of the main wordpress is copied into a new folder inside the wordpress main folder. The .htaccess file of the main wordpress is modified in order to redirect all the requests to the newly created folder. After this, the wp-config.php file located in the newly created folder is modified in order to add the prefix that has been used to create the duplicate tables to the line that defines the wordpress table prefix. Then all of the table using the old wordpress prefix are deleted. Then each export file of the database archive of the backup archive are imported into the database. Once this is done, the archive corresponding to the content of the main wordpress is then extracted from the backup archive into the main folder, ovewritting the .htaccess file as well.

When cloning the website into another server, a backup is created. The backup archive is then made available publicly to only one specified domain. The other server can then use a link to copy the backup archive into the new server.