Bench restore after new ERPNext install

Hi,

This might be a dumb question… but can you use bench restore on a different or new installation of ERPNext?

Scenario:

  1. Create backup of ERPNext
  2. Format server, reinstall ERPNext
  3. bench restore the back-up created in Step 1

Cheers!

Yes you can do this as long as the target server for the restore is the same version as the source server of the database backup.

However, you will also want to copy the encryption key from the source server and paste it into the site_config.json file of the target server so that everything else will work properly.

The restore command would be formatted like this:

sudo bench --force --site site1.local restore /path_to_sql_file

Where site1.local is the site name of the target server and path_to_sql_file is the location of the backup file to be restored.

BKM

Thanks for the info bkm.

This is what my site_config.json file looks like:

{
 "db_name": "_b7c06e947cbe3986",
 "db_password": "xxxxxxxxxxxx",
 "db_type": "mariadb",
 "developer_mode": 1,
 "enable_two_factor_auth": true,
 "maintenance_mode": 0,
 "pause_scheduler": 0
}

I have a couple of questions regarding this config file.

  1. There is no encryption key in my source config file, so I assume I can ignore that step?
  2. Does any other info from the config file need to come over, like db_name?

I’ve done a bench restore of a different server to test, however it’s having an issue with my custom doctypes. The doctypes are there in doctype list, however it’s throwing this error when I try to view the list view:

### App Versions

{
	"erpnext": "14.0.0",
	"frappe": "14.0.0",
	"payments": "0.0.1"
}

### Route

List/Lease Agreement/List

### Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1581, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/load.py", line 74, in getdoctype
    docs = get_meta_bundle(doctype)
  File "apps/frappe/frappe/desk/form/load.py", line 85, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "apps/frappe/frappe/desk/form/meta.py", line 45, in get_meta
    meta = FormMeta(doctype)
  File "apps/frappe/frappe/desk/form/meta.py", line 56, in __init__
    self.load_assets()
  File "apps/frappe/frappe/desk/form/meta.py", line 66, in load_assets
    self.add_code()
  File "apps/frappe/frappe/desk/form/meta.py", line 121, in add_code
    self.add_html_templates(path)
  File "apps/frappe/frappe/desk/form/meta.py", line 134, in add_html_templates
    for fname in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory: 'apps/erpnext/erpnext/accounts/doctype/lease_agreement'


### Request Data

{
	"type": "GET",
	"args": {
		"doctype": "Lease Agreement",
		"with_parent": 1,
		"cached_timestamp": null
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.load.getdoctype"
}

### Response Data
{
	"exception": "FileNotFoundError: [Errno 2] No such file or directory: 'apps/erpnext/erpnext/accounts/doctype/lease_agreement'"
}

Could this be a result of not performing bench migrate prior to backing up the site? I’m still new to the environment, but perhaps that migrate command complies all of my custom doctypes and modules?

How were the custom doctypes created?

The system isn’t able to locate lease_agreement doctype which doesn’t seem to be part of a standard installation.