Restore failing - V6

Hi Team,

Im trying to restore backup from last night from production server to dev server.

I copied the and ran the command as per instructions found at:

But I get this error - not sure why…any help will be appreciated.

hemant@ubuntu:~$ cd frappe-bench/sites/site1.local/private/backups/
hemant@ubuntu:~/frappe-bench/sites/site1.local/private/backups$ bench --force restore 20150907_18443861_database.sql
MySQL root password:
sh: 1: cannot open 20150907_18443861_database.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/hemant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/hemant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/hemant/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/hemant/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/hemant/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/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/hemant/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/hemant/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/hemant/frappe-bench/apps/frappe/frappe/commands.py”, line 131, 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/hemant/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/hemant/frappe-bench/apps/frappe/frappe/installer.py”, line 38, in install_db
remove_missing_apps()
File “/home/hemant/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/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 625, in get_global
return self.get_default(key, user)
File “/home/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 637, in get_default
d = frappe.defaults.get_defaults(parent).get(key)
File “/home/hemant/frappe-bench/apps/frappe/frappe/defaults.py”, line 49, in get_defaults
globald = get_defaults_for()
File “/home/hemant/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/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 135, in sql
self._cursor.execute(query, values)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, “Table ‘1bd3e0294d.tabDefaultValue’ doesn’t exist”)

Check your file name.

filename is correct, its why im confused…is it too long?

Check your path - the message is pretty clear that the file is not present

Hi Rushabh

here is the copy of the terminal window… I undestand that the message says the file does not exist but that implies that the message is correct :wink:

hemant@ubuntu:~$ cd frappe-bench/
hemant@ubuntu:~/frappe-bench$ ls sites/site1.local/private/backups/
20150907_18443861_database.sql.gz 20150909_17233520_database.sql.gz
20150908_54612026_database.sql 20150909_17233520_files.tar
20150908_54612026_database.sql.gz
hemant@ubuntu:~/frappe-bench$ bench --force restore sites/site1.local/private/backups/20150908_54612026_database.sql
MySQL root password:
sh: 1: cannot open sites/site1.local/private/backups/20150908_54612026_database.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/hemant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/hemant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/hemant/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/hemant/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/hemant/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/hemant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/hemant/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/hemant/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/hemant/frappe-bench/apps/frappe/frappe/commands.py”, line 131, 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/hemant/frappe-bench/apps/frappe/frappe/commands.py”, line 89, in _new_site
_install_app(“frappe”, verbose=verbose, set_as_patched=not source_sql)
File “/home/hemant/frappe-bench/apps/frappe/frappe/installer.py”, line 92, in install_app
frappe.clear_cache()
File “/home/hemant/frappe-bench/apps/frappe/frappe/init.py”, line 407, in clear_cache
for fn in frappe.get_hooks(“clear_cache”):
File “/home/hemant/frappe-bench/apps/frappe/frappe/init.py”, line 680, in get_hooks
hooks = _dict(cache().get_value(“app_hooks”, load_app_hooks))
File “/home/hemant/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 47, in get_value
val = generator()
File “/home/hemant/frappe-bench/apps/frappe/frappe/init.py”, line 648, in load_app_hooks
for app in [app_name] if app_name else get_installed_apps(sort=True):
File “/home/hemant/frappe-bench/apps/frappe/frappe/init.py”, line 633, in get_installed_apps
installed = json.loads(db.get_global(“installed_apps”) or “[]”)
File “/home/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 625, in get_global
return self.get_default(key, user)
File “/home/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 637, in get_default
d = frappe.defaults.get_defaults(parent).get(key)
File “/home/hemant/frappe-bench/apps/frappe/frappe/defaults.py”, line 49, in get_defaults
globald = get_defaults_for()
File “/home/hemant/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/hemant/frappe-bench/apps/frappe/frappe/database.py”, line 135, in sql
self._cursor.execute(query, values)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/hemant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, “Table ‘1bd3e0294d.tabDefaultValue’ doesn’t exist”)
hemant@ubuntu:~/frappe-bench$

Did you find a solution to this?

Happened the same to me.

I would try enclosing the file name in single quotes, ie,

$ bench --force restore ‘20150907_18443861_database.sql’

Hi @william

Use the full path to the sql file, so /home/hemant/sqlfile… you can put the file anywhere you like, just make sure you use the full path to it in the bench command

This worked for me.

Also if you have custom app make sure that it’s installed first before restoring.

Regards
Hemant

Thanks @hpema108

Get the error when I try with full path as you suggested.

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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, 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 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, 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 1060, 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 889, 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 534, 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.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/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=contex
t.verbose, install_apps=install_app, source_sql=sql_file_path, force=context.force)
  File "/home/frappe/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=so
urce_sql,force=force, reinstall=reinstall)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 31, in install_db
    create_database_and_user(force, verbose)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 53, in create_database_and_user
    raise Exception("Database %s already exists" % (db_name,))
Exception: Database 1bd3e0294d already exists

@william

I use these 2 commands and works for me everytime

gunzip /home/hemant/frappe-bench/sites/site1.local/private/backups/20160225_68146821_database.sql.gz
bench --force restore /home/hemant/frappe-bench/sites/site1.local/private/backups/ 20160225_68146821_database.sql

what command are you using?

regards

Yup.

Figured that out…

@hpema108 Thanks again!