Backupfile restore error

Hello,

I’m getting error when I tried to restore backup file as mentioned below.

ImportError: Module import failed for Subscription Plan Detail (frappe.core.doctype.subscription_plan_detail.subscription_plan_detail Error: No module named subscription_plan_detail.subscription_plan_detail)

can anyone help me.

Regards,
Sujay

Is this with the database backup or are you getting this error from the import/export data utility?

If you get this from running bench restore, then we need to know if the database you are restoring might have some custom additions that may not exist yet in the target system?

Also if you are getting this from bench restore, then try this version of the command:

`

sudo bench --force --site site1.local restore /path-to-your-backup-file

`
This is what I use and it even works when restoring a database form a different server.

Let us know what you did to get this error.

BKM

1 Like

Hello,

I used the command suggested by you, and after that I ran bench --site site1.local migrate.

I got this error.

root@ubuntu:/home/ubuntu# cd /home/frappe/
root@ubuntu:/home/frappe# cd frappe-bench/
root@ubuntu:/home/frappe/frappe-bench# cd sites/
root@ubuntu:/home/frappe/frappe-bench/sites# cd site1.local/
root@ubuntu:/home/frappe/frappe-bench/sites/site1.local# cd public/
root@ubuntu:/home/frappe/frappe-bench/sites/site1.local/public# cd files/
root@ubuntu:/home/frappe/frappe-bench/sites/site1.local/public/files# ls
20190318_120002_05f53e6f_database.sql
root@ubuntu:/home/frappe/frappe-bench/sites/site1.local/public/files# cd /home/frappe/
root@ubuntu:/home/frappe# cd frappe-bench/
root@ubuntu:/home/frappe/frappe-bench# sudo bench --force --site site1.local restore /sites/site1.local/public/files/20190318_120002_05f53e6f_database.sql
MySQL root password:
Creating Database…
172MiB 0:00:58 [2.94MiB/s] [=====================================================================================================================================================>] 100%
*** Scheduler is disabled ***
root@ubuntu:/home/frappe/frappe-bench# bench - -site site1.local migrate
Usage: bench [OPTIONS] COMMAND [ARGS]…

Bench manager for Frappe

Options:
–version
–help Show this message and exit.

Commands:
backup backup site
backup-all-sites backup all sites
config change bench configuration
disable-production Disables production environment for the bench.
download-translations Download latest translations
exclude-app Exclude app from updating
get-app clone an app from the internet and set it up in…
include-app Include app from updating
init Create a New Bench Instance.
install Install system dependancies
migrate-env Migrate Virtual Environment to desired Python…
new-app start a new app
prepare-beta-release Prepare major beta release from develop branch
release Release app (internal to the Frappe team)
remote-reset-url Reset app remote url to frappe official
remote-set-url Set app remote url
remote-urls Show apps remote url
remove-app completely remove app from bench
renew-lets-encrypt Renew Let’s Encrypt certificate
restart Restart supervisor processes or systemd units
retry-upgrade
set-default-site Set default site for bench
set-mariadb-host Set MariaDB host for bench
set-nginx-port Set nginx port for site
set-ssl-certificate Set ssl certificate path for site
set-ssl-key Set ssl certificate private key path for site
set-url-root Set url root for site
setup Setup bench
shell
src Prints bench source folder path, which can be used…
start Start Frappe development processes
switch-to-branch Switch all apps to specified branch, or specify…
switch-to-develop Switch frappe and erpnext to develop branch
switch-to-master Switch frappe and erpnext to master branch
update Update bench
root@ubuntu:/home/frappe/frappe-bench# bench --site site1.local migrate
Migrating site1.local
Executing frappe.patches.v8_0.drop_in_dialog #2017-09-22 in site1.local (1bd3e0294da19198)
Success: Done in 0.144s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘doctype’, force=True) #2017-09-22 in site1.local (1bd3e0294da19198)
Success: Done in 1.178s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2018-02-20 in site1.local (1bd3e0294da19198)
Success: Done in 1.261s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2018-05-29 in site1.local (1bd3e0294da19198)
Success: Done in 0.518s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘module_def’) #2017-09-22 in site1.local (1bd3e0294da19198)
Success: Done in 0.341s
Executing frappe.patches.v11_0.replicate_old_user_permissions in site1.local (1bd3e0294da19198)
Success: Done in 0.073s
Executing frappe.patches.v11_0.drop_column_apply_user_permissions in site1.local (1bd3e0294da19198)
Success: Done in 1.485s
Executing frappe.patches.v11_0.reload_and_rename_view_log #2019-01-03 in site1.local (1bd3e0294da19198)
Success: Done in 0.179s
Executing frappe.patches.v11_0.copy_fetch_data_from_options in site1.local (1bd3e0294da19198)
Success: Done in 2.007s
Executing frappe.patches.v11_0.change_email_signature_fieldtype in site1.local (1bd3e0294da19198)
Success: Done in 0.828s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘activity_log’) in site1.local (1bd3e0294da19198)
Success: Done in 0.423s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘domain_settings’) in site1.local (1bd3e0294da19198)
Success: Done in 0.136s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘user’) #2017-10-27 in site1.local (1bd3e0294da19198)
Success: Done in 0.03s
Executing frappe.patches.v8_1.delete_custom_docperm_if_doctype_not_exists in site1.local (1bd3e0294da19198)
Success: Done in 0.039s
Executing frappe.patches.v8_5.delete_email_group_member_with_invalid_emails in site1.local (1bd3e0294da19198)
Success: Done in 0.155s
Executing frappe.patches.v8_x.update_user_permission in site1.local (1bd3e0294da19198)
Success: Done in 1.515s
Executing frappe.patches.v8_5.patch_event_colors in site1.local (1bd3e0294da19198)
Success: Done in 0.053s
Executing frappe.patches.v8_10.delete_static_web_page_from_global_search in site1.local (1bd3e0294da19198)
Success: Done in 0.03s
Executing frappe.patches.v9_1.add_sms_sender_name_as_parameters in site1.local (1bd3e0294da19198)
Success: Done in 0.285s
Executing frappe.patches.v9_1.resave_domain_settings in site1.local (1bd3e0294da19198)
Success: Done in 0.099s
Executing frappe.patches.v9_1.revert_domain_settings in site1.local (1bd3e0294da19198)
Success: Done in 0.763s
Executing frappe.patches.v9_1.move_feed_to_activity_log in site1.local (1bd3e0294da19198)
Success: Done in 11.998s
Executing execute:frappe.delete_doc(‘Page’, ‘data-import-tool’, ignore_missing=True) in site1.local (1bd3e0294da19198)
Success: Done in 1.685s
Executing frappe.patches.v10_0.reload_countries_and_currencies in site1.local (1bd3e0294da19198)
Updating country info : [========================================]
Success: Done in 0.727s
Executing frappe.patches.v10_0.refactor_social_login_keys in site1.local (1bd3e0294da19198)
Success: Done in 2.082s
Executing frappe.patches.v10_0.enable_chat_by_default_within_system_settings in site1.local (1bd3e0294da19198)
Success: Done in 3.553s
Executing frappe.patches.v10_0.remove_custom_field_for_disabled_domain in site1.local (1bd3e0294da19198)
Success: Done in 0.282s
Executing execute:frappe.delete_doc(“Page”, “chat”) in site1.local (1bd3e0294da19198)
Success: Done in 0.201s
Executing frappe.patches.v10_0.migrate_passwords_passlib in site1.local (1bd3e0294da19198)
Success: Done in 2.718s
Executing frappe.patches.v11_0.rename_standard_reply_to_email_template in site1.local (1bd3e0294da19198)
Success: Done in 2.204s
Executing execute:frappe.delete_doc_if_exists(‘Page’, ‘user-permissions’) in site1.local (1bd3e0294da19198)
Success: Done in 0.389s
Executing frappe.patches.v10_0.set_no_copy_to_workflow_state in site1.local (1bd3e0294da19198)
Success: Done in 0.061s
Executing frappe.patches.v10_0.increase_single_table_column_length in site1.local (1bd3e0294da19198)
Success: Done in 0.039s
Executing frappe.patches.v11_0.create_contact_for_user in site1.local (1bd3e0294da19198)
Success: Done in 24.094s
Executing frappe.patches.v11_0.sync_stripe_settings_before_migrate in site1.local (1bd3e0294da19198)
Success: Done in 0.036s
Executing frappe.patches.v11_0.update_list_user_settings in site1.local (1bd3e0294da19198)
Success: Done in 0.462s
Executing frappe.patches.v11_0.rename_workflow_action_to_workflow_action_master #13-06-2018 in site1.local (1bd3e0294da19198)
Success: Done in 1.364s
Executing frappe.patches.v11_0.rename_email_alert_to_notification #13-06-2018 in site1.local (1bd3e0294da19198)
Success: Done in 3.68s
Executing frappe.patches.v11_0.delete_duplicate_user_permissions in site1.local (1bd3e0294da19198)
Success: Done in 0.048s
Executing frappe.patches.v11_0.set_dropbox_file_backup in site1.local (1bd3e0294da19198)
Success: Done in 1.018s
Executing frappe.patches.v10_0.set_default_locking_time in site1.local (1bd3e0294da19198)
Success: Done in 0.035s
Executing frappe.patches.v11_0.rename_google_maps_doctype in site1.local (1bd3e0294da19198)
Success: Done in 0.04s
Executing frappe.patches.v10_0.modify_smallest_currency_fraction in site1.local (1bd3e0294da19198)
Success: Done in 0.033s
Executing frappe.patches.v10_0.modify_naming_series_table in site1.local (1bd3e0294da19198)
Success: Done in 0.067s
Executing frappe.patches.v10_0.enhance_security in site1.local (1bd3e0294da19198)
Success: Done in 2.695s
Executing frappe.patches.v11_0.multiple_references_in_events in site1.local (1bd3e0294da19198)
Success: Done in 0.768s
Executing frappe.patches.v11_0.set_allow_self_approval_in_workflow in site1.local (1bd3e0294da19198)
Success: Done in 0.325s
Executing frappe.patches.v11_0.remove_skip_for_doctype in site1.local (1bd3e0294da19198)
Success: Done in 19.875s
Executing frappe.patches.v11_0.migrate_report_settings_for_new_listview in site1.local (1bd3e0294da19198)
Success: Done in 0.24s
Executing frappe.patches.v11_0.delete_all_prepared_reports in site1.local (1bd3e0294da19198)
Success: Done in 0.073s
Executing frappe.patches.v11_0.fix_order_by_in_reports_json in site1.local (1bd3e0294da19198)
Success: Done in 0.035s
Executing execute:frappe.delete_doc(‘Page’, ‘applications’, ignore_missing=True) in site1.local (1bd3e0294da19198)
Success: Done in 0.19s
Executing frappe.patches.v11_0.set_missing_creation_and_modified_value_for_user_permissions in site1.local (1bd3e0294da19198)
Success: Done in 0.051s
Executing frappe.patches.v11_0.remove_doctype_user_permissions_for_page_and_report in site1.local (1bd3e0294da19198)
Success: Done in 0.066s
Executing erpnext.patches.v8_9.set_print_zero_amount_taxes in site1.local (1bd3e0294da19198)
Success: Done in 0.712s
Executing erpnext.patches.v11_0.rename_production_order_to_work_order in site1.local (1bd3e0294da19198)
rename_field: work_order not found in Timesheet
Success: Done in 7.694s
Executing erpnext.patches.v11_0.refactor_naming_series in site1.local (1bd3e0294da19198)
Success: Done in 0.618s
Executing erpnext.patches.v11_0.refactor_autoname_naming in site1.local (1bd3e0294da19198)
Success: Done in 0.305s
Executing erpnext.patches.v10_0.rename_schools_to_education in site1.local (1bd3e0294da19198)
Success: Done in 2.08s
Executing erpnext.patches.v5_7.update_item_description_based_on_item_master in site1.local (1bd3e0294da19198)
Success: Done in 0.292s
Executing execute:frappe.reload_doc(“stock”, “doctype”, “stock_settings”) in site1.local (1bd3e0294da19198)
Success: Done in 0.259s
Executing execute:frappe.db.sql(“update tabStock Entry set total_amount = 0 where purpose in(‘Repack’, ‘Manufacture’)”) in site1.local (1bd3e0294da19198)
Success: Done in 0.031s
Executing erpnext.patches.v9_0.remove_subscription_module in site1.local (1bd3e0294da19198)
Success: Done in 0.223s
Executing erpnext.patches.v8_7.make_subscription_from_recurring_data in site1.local (1bd3e0294da19198)
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
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/local/lib/python2.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 227, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 38, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v8_7/make_subscription_from_recurring_data.py”, line 27, in execute
make_subscription(doctype, data, date_field)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v8_7/make_subscription_from_recurring_data.py”, line 55, in make_subscription
}).insert(ignore_permissions=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 211, in insert
self._set_defaults()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 598, in _set_defaults
new_doc = frappe.new_doc(df.options, as_dict=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 658, in new_doc
return get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 21, in get_new_doc
frappe.local.new_doc_templates[doctype] = make_new_doc(doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 39, in make_new_doc
“docstatus”: 0
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 724, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 67, in get_doc
controller = get_controller(doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 36, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 187, in load_doctype_module
raise ImportError(‘Module import failed for {0} ({1})’.format(doctype, module_name + ’ Error: ’ + str(e)))
ImportError: Module import failed for Subscription Plan Detail (frappe.core.doctype.subscription_plan_detail.subscription_plan_detail Error: No module named subscription_plan_detail.subscription_plan_detail)
root@ubuntu:/home/frappe/frappe-bench#

Please help.

Hello,

I again tried to reinstall using this command, bench --site sitename reinstall.

After installing it I tried sudo bench --force --site site1.local restore /path-to-your-backup-file.

And when I go to my browser and refreshed it I got this error.

First, it appears you are running al commands in ‘root’ user. This will cause some errors. All commands should be run as a non-root user (usually frappe user).

Next we need to know if you are restoring a database from v10 to a ERPNext install of v11. That is usually how the migrate error would occur.

If you are trying to get from v10 to v11 you should run the update and migrate from a v10 installation and this will upgrade everything to v11 for you (usually without errors).

BKM

Hello,

The current version which we are using is ERPNext: v8.3.5 (master) & Frappe Framework: v8.3.8 (master).

I have installed a newer version v11.1.14 in other server.

So, I have downloaded the backup file from version 8 through download backup option under setup.

Now I’m trying to restore it into the newer version.

Hello,

I again reinstalled erpnext and tried restoring from frappe user,

I’m getting same error.

ImportError: Module import failed for Subscription Plan Detail (frappe.core.doctype.subscription_plan_detail.subscription_plan_detail Error: No module named subscription_plan_detail.subscription_plan_detail)
frappe@ubuntu:~/frappe-bench$

Okay, this is probably your problem. You cannot restore a backup from an older version to a newer version. You have to use the older version to preform the update/upgrade process. The upgrade process alters the database to whatever the newer database configuration is for each version.

So, in order to get from v8 to v11, you have to first upgrade to v9, then upgrade v9 to v10, then upgrade v10 to v11. This way each of the database changes across each of the versions is executed on the database in the correct order to get you to the new version.

If you want a shorter approach, it will require the assistance of an accomplished mysql developer to help you convert the database first.

BKM

So can you just suggest me the commands which i need to use to have a safe upgradation.

This will likely require the assistance of a developer or an expert. If you do a forum search on upgrading from v8 to v10 you will find several threads devoted to this process. In almost every case it required patching some scripts before attempting to execute a new level of upgrade.

I have seen you errors before so I was able to identify the problem. The solution is going to be a bit more complex. I suggest starting a new thread asking for instructions about how to upgrade from v8 to v10 or v11.

BKM

@bkm Was trying to restore from backup created using the Poor Man’s Backup Setup but i get this error everytime:

ERROR 1 (HY000) at line 66: Can’t create/write to file ‘/tmp/MLaoVLco’ (Errcode: 13 “Permission denied”)

Have you encountered this before? If yes, how did you resolve it?

No, I have not encountered that error before.

When “restoring” a backup file, there is no process that I am aware of that attempts to create or write to any temporary file. So this error does not make any sense.

BKM

@bkm it is particularly weird because restoring from a dropbox backup on the same instance completes without the same error.

Let us try this again…

I remembered getting a “Permission denied” error in the past and traced it back to a problem with a corruption in the database structure that is being overwritten with the restore command. I went back to my very old notes but could not remember if the error was the same as yours, but I did manage to get past it by doing the following:

On a separate testing system or other installation that is of the same version as the system you need to restore, login as Administrator.

Then type “company” into the awesome bar and select Company List from the drop down

Then select the Company and scroll all the way to the bottom of the document and click on “Delete Company Transactions”

This will wipe out almost all of the data (minus the master files like supplier, etc.)

Then run a backup of the almost blank database.

When it is done, take that database and restore it over the potentially corrupted one.

If it does NOT generate an error, then you should be able to restore your live database over the now almost empty one without any errors.

If you still get errors, then the problem may be a corruption in the database you are attempting to restore.

This process may not fix your particular problem, but it did get past something similar for me in versions 9 and 10.

If you have any other blank database available you can try restoring it over the corrupted one and try your live data again.

Hope this helps.

BKM

That is an indication that the database you are attempting to restore may be damaged.

Have you tried maybe using the backup before this one or one after it to see if it is just one corrupted compressed file?

BKM

I currently have over a dozen Poor Mans Backup v2 systems running that get restored every weekend. They have been running for about a year now. None of them have ever generated an error and they all get tested after restore.

I have several other forum users that PM me with their success stories with this process as well. This makes me think something has happened to your compressed file before you tried to unzip it and restore it.

Do let me know what you find.

BKM