I move sites multiple times, from a server to another or from a multitenant configuration to a single tenant.
The key is to create a backup with bench backup, database backup are stored in my_site/files/private/backup/
So here my workflow :
In the new server :
- Install bench manually or with installation script
- Setup a new bench with specific frappe version
bench init --python python3 --frappe-branch version-11 my-benchfor example - From your new bench instance get your app :
bench get-app --branch version erpnext - Next is where you will need to copy files from your backup server to your new server in a backup directory (not inside the current bench)
- Get your backup site (only the site folder is required unless you have configured some elements globally)
- unzip your last database backup inside your new server :
gunzip my_site/files/private/backup/my_sitexxxx.sql.gz - From your new bench install a new site with this backup :
bench new-site --source_sql /full/path/to/your/backup.sql my_new_siteNow you will have your site inside your new bench - Copy files from your backup inside your new new site :
cp -R backup/my-site/files/private/ my-bench/sites/my-site/files/andcp -R backup/my-site/files/public/ my-bench/sites/my-site/files/ - Next you must copy the “encryption_key” from your backup my-site/site_config.json, to your new-site if you want to be able to read emails in your new instance
- now all is prepared to run the bench setup production, bench setup lets-encrypt and another bench update
I have script that in a bash script to ‘restore-site’ with all this steps in my servers.
And I also backup only datas (databases, files folder and site_config.json)
Regards.