Restore the .sql in erpnextv6.2 Dir frappe-bench

Hi,

How to Restore The sql file in frappe-bench.in ver6.2…
When i try with this command this error is occured…
ikhlas3@ikhlas3:~/frappe-bench/sites$ frappe --restore site file:///home/ikhlas3/frappe-bench/ssh4.sql
MySQL root password:
Traceback (most recent call last):
File “/usr/local/bin/frappe”, line 9, in
load_entry_point(‘frappe==4.7.1’, ‘console_scripts’, ‘frappe’)()
File “/home/ikhlas3/bench/apps/frappe/frappe/cli.py”, line 53, in main
return run(fn, parsed_args)
File “/home/ikhlas3/bench/apps/frappe/frappe/cli.py”, line 81, in run
out = globals().get(fn)(*args.get(fn), **args)
File “/home/ikhlas3/bench/apps/frappe/frappe/cli.py”, line 67, in new_fn
return fn(*args, **new_kwargs)
File “/home/ikhlas3/bench/apps/frappe/frappe/cli.py”, line 378, in restore
_install(db_name, source_sql=source_sql, quiet=quiet, force=force)
File “/home/ikhlas3/bench/apps/frappe/frappe/cli.py”, line 309, in _install
admin_password = admin_password, verbose=verbose, force=force, site_config=site_config, reinstall=reinstall)
File “/home/ikhlas3/bench/apps/frappe/frappe/installer.py”, line 31, in install_db
create_database_and_user(force, verbose)
File “/home/ikhlas3/bench/apps/frappe/frappe/installer.py”, line 52, in create_database_and_user
raise Exception(“Database %s already exists” % (db_name,))
Exception: Database 1bd3e0294d already exists
ikhlas3@ikhlas3:~/frappe-bench/sites$

go to frappe bench folder and run this command

bench restore file:///home/ikhlas3/frappe-bench/ssh4.sql

For restoring database, try this(be careful, bench reinstall will delete existing site data)

bench --site {sitename} --force reinstall
bench --site {sitename} install-app erpnext 
bench --force restore {sql file}
1 Like

where i use a new site ??? in a bench --force restore {sql file}??? Please give the command step by step…

Run these commands from frappe-bench directory:

bench new-site {newsitename}
bench --force --site {newsitename} restore file:///home/ikhlas3/frappe-bench/ssh4.sql

Hi nabinhait,
using Ure mention command this error is come!!!
ikhlas@Ikhlas:~/erpnext/frappe-bench$ bench --force --site kkma restore kkmark.sql
MySQL root password:
sh: 1: cannot open kkmark.sql: No such file
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, 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/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 130, in restore
_new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=context.verbose, install_apps=install_app, source_sql=sql_file_path, force=context.force)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 87, in _new_site
install_db(root_login=mariadb_root_username, root_password=mariadb_root_password, db_name=db_name, admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/installer.py”, line 38, in install_db
remove_missing_apps()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/installer.py”, line 293, in remove_missing_apps
installed_apps = json.loads(frappe.db.get_global(“installed_apps”) or “[]”)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 641, in get_global
return self.get_default(key, user)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 653, in get_default
d = frappe.defaults.get_defaults(parent).get(key)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/defaults.py”, line 49, in get_defaults
globald = get_defaults_for()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/defaults.py”, line 154, in get_defaults_for
where parent = %s order by creation"“”, (parent,), as_dict=1)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 135, in sql
self._cursor.execute(query, values)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, “Table ‘eaa7c5c90b.tabDefaultValue’ doesn’t exist”)
ikhlas@Ikhlas:~/erpnext/frappe-bench$

Try with the full, absolute path to kkmark.sql (eg, /home/user/kkmark.sql)

@pdvyas…Now i give exact path Also but i got a same error…
ikhlas@Ikhlas:~/erpnext/frappe-bench$ bench --force --site ikhkm restore file:///home/ikhlas3/erpnext/frappe-bench/kkmark.sql
MySQL root password:
sh: 1: cannot open file:///home/ikhlas3/erpnext/frappe-bench/kkmark.sql: No such file
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, 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/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 130, in restore
_new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=context.verbose, install_apps=install_app, source_sql=sql_file_path, force=context.force)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/commands.py”, line 87, in _new_site
install_db(root_login=mariadb_root_username, root_password=mariadb_root_password, db_name=db_name, admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/installer.py”, line 38, in install_db
remove_missing_apps()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/installer.py”, line 293, in remove_missing_apps
installed_apps = json.loads(frappe.db.get_global(“installed_apps”) or “[]”)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 641, in get_global
return self.get_default(key, user)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 653, in get_default
d = frappe.defaults.get_defaults(parent).get(key)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/defaults.py”, line 49, in get_defaults
globald = get_defaults_for()
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/defaults.py”, line 154, in get_defaults_for
where parent = %s order by creation"“”, (parent,), as_dict=1)
File “/home/ikhlas/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 135, in sql
self._cursor.execute(query, values)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/ikhlas/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, “Table ‘28452f2ee9.tabDefaultValue’ doesn’t exist”)

skip the file:/// part

bench --force --site ikhkm restore /home/ikhlas3/erpnext/frappe-bench/kkmark.sql

@pdvyas… Yeah Thanks For all…When i open the browser…
ImportError: No module named shopping_cart_settings.shopping_cart_settings

This error is came on browser.

Is the backup from v4?
Can you try bench update

shopping_cart module was a separate module in version 4 and earlier and from ERPNext version 5, it is now part of core package.
It seems sql file you are trying to restore does have traces of old module or maybe your ERPNext app is not loaded properly from github repository, please investigate…

try running:

$ bench retry-upgrade
$ bench --site yoursitename migrate

S…back up of v4. some error in bench update…

Thanks & Regards,
Mohamed Sajid Waqir.

@pdvyas bench update error
ikhlas@Ikhlas:~/erpnext/frappe-bench$ bench update
Already up-to-date.
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./env/lib/python2.7/site-packages
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript

  • branch master → FETCH_HEAD
    Already up-to-date.
    From GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
  • branch master → FETCH_HEAD
    Already up-to-date.
    Migrating site1.local
    Updating frappe : [========================================]
    Updating erpnext : [========================================]
    Wrote ./assets/js/print_format_v3.min.js - 18k
    Wrote ./assets/js/frappe-web.min.js - 275k
    Wrote ./assets/js/form.min.js - 100k
    Wrote ./assets/js/report.min.js - 155k
    Wrote ./assets/js/erpnext.min.js - 34k
    Wrote ./assets/css/list.min.css - 6k
    Wrote ./assets/js/erpnext-web.min.js - 1k
    Wrote ./assets/css/report.min.css - 7k
    Wrote ./assets/css/frappe-web.css - 53k
    Wrote ./assets/js/list.min.js - 63k
    Wrote ./assets/js/desk.min.js - 863k
    Wrote ./assets/css/form.min.css - 2k
    Wrote ./assets/js/editor.min.js - 26k
    Wrote ./assets/css/erpnext.css - 1k
    Wrote ./assets/css/desk.min.css - 255k
    Wrote ./assets/js/module.min.js - 5k
    Wrote ./assets/css/module.min.css - 1k
    error: , : file: /usr/lib/python2.7/xmlrpclib.py line: 794
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 9, in
    load_entry_point(‘bench==0.92’, ‘console_scripts’, ‘bench’)()
    File “/home/ikhlas/erpnext/bench-repo/bench/cli.py”, line 60, in cli
    bench()
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 700, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 680, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1027, in invoke
    return processresult(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 508, in invoke
    return callback(*args, **kwargs)
    File “/home/ikhlas/erpnext/bench-repo/bench/cli.py”, line 240, in _update
    update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
    File “/home/ikhlas/erpnext/bench-repo/bench/cli.py”, line 279, in update
    restart_supervisor_processes(bench=bench_path)
    File “/home/ikhlas/erpnext/bench-repo/bench/utils.py”, line 303, in restart_supervisor_processes
    exec_cmd(cmd, cwd=bench)
    File “/home/ikhlas/erpnext/bench-repo/bench/utils.py”, line 104, in exec_cmd
    raise CommandFailedError(cmd)
    bench.utils.CommandFailedError: sudo supervisorctl restart frappe:
    How to fix this error?

@Mohamed_Sajid
How come DB from older version will work with new version? at least it does not work in case of ERPNext.

Do following steps to overcome all installation issues you are facing:
If possible start fresh with bench tool setup with production mode - more: GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps

Once frappe and erpnext is installed successfully,

  1. switch to frappe user prompt CMD : su - frappe
  2. run following commands in correct sequence:
    $ bench switch-to-v4
    $ bench migrate
    $ bench new-site {sitename-OR-fqdn} --install-app erpnext
    $ bench --force --site {sitename-OR-fqdn} restore {replace-with-correct-path-to-sql-file eg./home/frappe/frappe-bench/kkmark.sql}
    $ bench retry-upgrade
    $ bench switch-to-master
    $ bench migrate

@yashodhan ow to switch to frappe in Ubuntu…
ikhlas@Ikhlas:~/erpnext/frappe-bench$ su - frappe
Unknown id: frappe

you can skip that step of switching to frappe user

Now i doing Only one step $bench switch-do-v4.
now i want chang into update version v6.8…How ll change to latest version???v6.8

bench switch-to-master followed by bench migrate will switch to latest stable version eg. 6.x
@Mohamed_Sajid, I have already provided you list of commands to migrate your version 4 to version 6

Please take a look, if su - frappe did not work, it means you are still using old or manual installation method for bench, we wont be able to help you. unless you follow and apply some your own logic.

1 Like

ikhlas@Ikhlas:~/erpnext/frappe-bench$ bench switch-to-master
remote: Counting objects: 175, done.
remote: Total 175 (delta 156), reused 156 (delta 156), pack-reused 19
Receiving objects: 100% (175/175), 26.34 KiB | 13 KiB/s, done.
Resolving deltas: 100% (156/156), completed with 153 local objects.
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
2edaaa1…6567093 develop → upstream/develop
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.92’, ‘console_scripts’, ‘bench’)()
File “/home/ikhlas/sajid/bench-repo/bench/cli.py”, line 60, in cli
bench()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/ikhlas/sajid/bench-repo/bench/cli.py”, line 321, in _switch_to_master
switch_to_master(upgrade=upgrade)
File “/home/ikhlas/sajid/bench-repo/bench/app.py”, line 177, in switch_to_master
switch_branch(‘master’, apps=apps, bench=bench, upgrade=upgrade)
File “/home/ikhlas/sajid/bench-repo/bench/app.py”, line 150, in switch_branch
raise MajorVersionUpgradeException(“Switching to {0} will cause upgrade from {1} to {2}. Pass --upgrade to confirm”.format(branch, version_upgrade[1], version_upgrade[2]), version_upgrade[1], version_upgrade[2])
bench.app.MajorVersionUpgradeException: Switching to master will cause upgrade from 4 to 6. Pass --upgrade to confirm

bench.app.MajorVersionUpgradeException: Switching to master will cause upgrade from 4 to 6. Pass --upgrade to confirm

bench switch-to-master --upgrade