Renaming a site and create a new one

I have a site at erp.example.com up and running.

I am planning to move the site to old.example.com and install a fresh site at erp.example.com.

What is the proper way to do this with out reinstalling OS or without this step:
→ backup erp.example.com
→ create new site old.example.com
→ restore backup from erp.example.com in old.example.com
→ drop erp.example.com
→ create new site erp.example.com ?

Is there a proper way to rename a site ?

(I already have dns based multitenancy.)

@anupd If you want, you can follow these steps

Steps to Rename a Site in Frappe:

  1. Stop the Bench Server
    → bench stop
  2. Rename the Site Directory
    → cd ~/frappe-bench/sites/
    → mv old_site_name new_site_name
  3. Update the site_config.json File
    → Generally, you don’t need to change much here, but make sure the configuration aligns with the new site name if any entries refer to the old name.
    → nano ~/frappe-bench/sites/new_site_name/site_config.json
  4. Update the Database Settings (Optional)
    → If you want to rename the database associated with the site (this step is optional), you will need to:
    → mysql -u root -p RENAME DATABASE old_site_name_db TO new_site_name_db;
    → Update db_name in the site_config.json to match the new database name:
    {“db_name”: “new_site_name_db”}
  5. Clear the Cache and Rebuild

bench --site new_site_name clear-cache
bench --site new_site_name clear-website-cache
bench --site new_site_name build

  1. Start Bench:
    → bench start
  2. Update Hosts File (If Needed):

Important Notes:

  • If you are renaming the site in a production environment, ensure you take appropriate backups (files and database) before proceeding.
  • Renaming the site does not automatically rename the database, so if you prefer the database name to match the new site name, you’ll have to rename it manually as described.
  • If you’re running multiple sites and using a proxy (like nginx), you may also need to update your nginx configuration for the new site name.
1 Like