Upgrade error from v13 to v14

I’m using frappe_docker to run v14.
For a new site all is OK but when I try to upgrade an existing site I have an issue

First I run command to restore my v13 backup

docker compose --project-name ao_v14 exec backend \
  bench --site mysite.com restore mysite.com/20220825_105350-mysite-database.sql --force

Next I run the migrate command on this restore

docker compose --project-name ao_v14 exec backend \
  bench --site mysite.com migrate

Here is the log of migration command

/home/frappe/frappe-bench/apps/frappe/frappe/database/query.py:197: UserWarning: The 'filters_config' hook used to add custom operators is not yet implemented in frappe.db.query engine. Use db_query (frappe.get_list) instead.
  warn(
Executing execute:frappe.reload_doc('core', 'doctype', 'doctype_state', force=True) #2021-12-15 in mysite.com (_3bed87e23093e821)
Success: Done in 0.427s
Executing execute:frappe.reload_doc('core', 'doctype', 'doctype') #2022-06-21 in mysite.com (_3bed87e23093e821)
Success: Done in 0.729s
Executing frappe.patches.v13_0.jinja_hook in mysite.com (_3bed87e23093e821)
Success: Done in 0.035s
Executing frappe.patches.v13_0.update_notification_channel_if_empty in mysite.com (_3bed87e23093e821)
Success: Done in 0.413s
Executing execute:frappe.reload_doc('custom', 'doctype', 'custom_field') in mysite.com (_3bed87e23093e821)
Success: Done in 0.496s
Executing frappe.patches.v14_0.update_workspace2 # 20.09.2021 in mysite.com (_3bed87e23093e821)
Success: Done in 2.633s
Executing frappe.patches.v14_0.save_ratings_in_fraction #23-12-2021 in mysite.com (_3bed87e23093e821)
Success: Done in 1.656s
Executing frappe.patches.v14_0.transform_todo_schema in mysite.com (_3bed87e23093e821)
Success: Done in 0.369s
Executing frappe.patches.v14_0.remove_post_and_post_comment in mysite.com (_3bed87e23093e821)
Success: Done in 0.257s
Executing frappe.patches.v14_0.reset_creation_datetime in mysite.com (_3bed87e23093e821)
        Resetting creation datetimes for DocTypes
Success: Done in 0.309s
Executing frappe.patches.v14_0.remove_is_first_startup in mysite.com (_3bed87e23093e821)
Success: Done in 0.043s
Executing frappe.patches.v14_0.clear_long_pending_stale_logs in mysite.com (_3bed87e23093e821)
        Due to large size of log tables on old sites some table cleanups never finished during daily log clean up. This patch discards such data by using "big delete" code.

                ref: https://github.com/frappe/frappe/issues/16971

Clearing old Email Queue records
Clearing old Email Queue Recipient records
Success: Done in 0.751s
Executing frappe.patches.v14_0.log_settings_migration in mysite.com (_3bed87e23093e821)
Success: Done in 0.706s
Executing frappe.patches.v14_0.setup_likes_from_feedback in mysite.com (_3bed87e23093e821)
Success: Done in 0.392s
Executing frappe.patches.v14_0.update_webforms in mysite.com (_3bed87e23093e821)
Success: Done in 1.183s
Executing frappe.patches.v14_0.delete_payment_gateways in mysite.com (_3bed87e23093e821)
Success: Done in 0.671s
Executing erpnext.patches.v14_0.change_is_subcontracted_fieldtype in mysite.com (_3bed87e23093e821)
Success: Done in 4.595s
Executing erpnext.patches.v13_0.add_doctype_to_sla #14-06-2021 in mysite.com (_3bed87e23093e821)
Success: Done in 0.773s
Executing erpnext.patches.v13_0.update_response_by_variance in mysite.com (_3bed87e23093e821)
Success: Done in 0.096s
Executing erpnext.patches.v14_0.update_opportunity_currency_fields in mysite.com (_3bed87e23093e821)
Success: Done in 0.936s
Executing erpnext.patches.v13_0.healthcare_deprecation_warning in mysite.com (_3bed87e23093e821)
Healthcare Module is moved to a separate app and will be removed from ERPNext in version-14.
Please install the app to continue using the module: https://github.com/frappe/healthcare
Success: Done in 0.036s
Executing erpnext.patches.v13_0.create_ksa_vat_custom_fields # 07-01-2022 in mysite.com (_3bed87e23093e821)
Success: Done in 0.09s
Executing erpnext.patches.v14_0.migrate_crm_settings in mysite.com (_3bed87e23093e821)
Success: Done in 0.241s
Executing erpnext.patches.v13_0.update_asset_quantity_field in mysite.com (_3bed87e23093e821)
Success: Done in 0.661s
Executing erpnext.patches.v13_0.non_profit_deprecation_warning in mysite.com (_3bed87e23093e821)
Non Profit Domain is moved to a separate app and will be removed from ERPNext in version-14.
When upgrading to ERPNext version-14, please install the app to continue using the Non Profit domain: https://github.com/frappe/non_profit
Success: Done in 0.035s
Updating DocTypes for frappe        : [============                            ] 31%Updating Dashboard for frappe
Updating Dashboard for erpnext
Updating customizations for Address
Updating customizations for Contact
Building search index for mysite.com
Retrieving Routes                   : [========================================] 100%
Building Index                      : [========================================] 100%
Traceback (most recent call last):
  File "/usr/local/bin/patched_bench_helper.py", line 48, in <module>
    raise SystemExit(main())
  File "/usr/local/bin/patched_bench_helper.py", line 43, in main
    frappe.utils.bench_helper.main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 523, in migrate
    SiteMigration(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 172, in run
    self.run_schema_updates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 40, in wrapper
    ret = method(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 112, in run_schema_updates
    frappe.model.sync.sync_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py", line 19, in sync_all
    sync_for(app, force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py", line 80, in sync_for
    import_file_by_path(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 145, in import_file_by_path
    import_doc(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 234, in import_doc
    delete_old_doc(doc, reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 277, in delete_old_doc
    frappe.delete_doc(doc.doctype, doc.name, force=1, ignore_doctypes=ignore, for_reload=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1253, in delete_doc
    return frappe.model.delete_doc.delete_doc(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 134, in delete_doc
    doc.run_method("after_delete")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 928, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1268, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1250, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 925, in fn
    return method_object(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/doctype/workspace/workspace.py", line 46, in after_delete
    delete_folder(self.module, "Workspace", self.title)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/export_file.py", line 106, in delete_folder
    shutil.rmtree(folder)
  File "/usr/local/lib/python3.10/shutil.py", line 724, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 657, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 680, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/local/lib/python3.10/shutil.py", line 678, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'settings.json'

There are some issues I don’t understand, could you please help me ?

Thanks.

This is a known issue:

It should be fixed by:

Many thanks @snv, so it’s in develop branch, I need to wait a new frappe release to get this patch and try again. Have you got any ETA for this one ?

Best regards.

Patch is working, I have finished my migration, many thanks to Frappe Team