Newbie: How to backup?

I had installed ERPNext by easiest method yesterday. I had done whole night to configure everything. Now wants to backup the Database, and Files as well. Important is database. That doesn’t mean that I didn’t gone through any disccussion thread or wiki.

  1. Data backup and restore - #2 by Francois_Ifitwala
  2. Backup & Restore - #9 by revant_one
  3. Restoring From ERPNext Backup · frappe/erpnext Wiki · GitHub
  4. Backup and Restore procedure - #12 by h_warrior
    & list is much more.

I had tried to traverse, file structure as well as terminal. bench backups commands and everything.

Here, Restoring From ERPNext Backup · frappe/erpnext Wiki · GitHub brief description looks incomplete for newbie. There is no wget URL, if I have than why I could roam here and there. Suitable example or flow should be there. Please help me with complete terminal commands to backup.

I’m having ubuntu 14.04. *waiting

1 Like

Open your site on the browser. Go to the Setup Module. Find a section called data. It has a link called download backups.

2 Likes

hi asharamseervi

and to restore the backup to new site use:
$ bench new-site (site-name) bench --force --site {newsitename} restore /path/to/file/sql.gz

and if you have already exist site use:
$ bench --site (site-name) --force restore /path/to/sql/dbname.sql.gz

and copy static files like images manually

2 Likes

I had tried this option too many times. Don’t know why, page always blanks. When frustrated, used commands on terminal, still hopeless. After Logout and signin, resolved this as per you suggested. Now, Another Question. Is this complete site database, or just one user or partial database.

In case, I change server. Database backuped now, easily import to the system? or need to configure something?

Thanks @PyJumper I had also tried this earlier, Don’t know why hopeless. Anyway, Now resolved.

1 Like

Also try setting up Dropbox backup. It is a really nice feature.

Although Brother @Sagar_Vora, I was not able to backup via Drop Box on deployed server. I had integrated DropBox Cammands via terminal as mentiond on thread. But, While at “Dropbox Settings” allow Dropbox access produces errors. Here it is:

Traceback (most recent call last): File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 56, in application response = frappe.handler.handle() File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle execute_cmd(cmd) File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 42, in execute_cmd ret = frappe.call(method, **frappe.form_dict) File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 907, in call return fn(*args, **newargs) File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/dropbox_settings/dropbox_settings.py", line 54, in get_dropbox_authorize_url request_token = sess.obtain_request_token() File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dropbox/session.py", line 216, in obtain_request_token response = self.rest_client.POST(url, headers=headers, params=params, raw_response=True) File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dropbox/rest.py", line 322, in POST return cls.IMPL.POST(*n, **kw) File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dropbox/rest.py", line 260, in POST is_json_request=is_json_request) File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dropbox/rest.py", line 235, in request raise ErrorResponse(r, r.read()) ErrorResponse: [401] u'Unauthorized'

Any Solutions Please? or steps follow to install it properly?

I had encountered the same issue.
Pass this command from frappe-bench directory:
env/bin/pip install google-api-python-client

Had done this. Still getting same error. Even cache clear as well. But Still.

I tried to replicate this at my end. And I got the error. But I solved it.

I entered the app key and app secret manually and saved the settings.
Then, I cleared browser cache and tried again. It worked!

PS: If you’re using Chrome, you’ll have to allow the popup.

1 Like
  • Did you generate the app key and secret here?
  • Did you enter the key and secret manually in the fields like I suggested?
  • DId you allow popups for the site?
1 Like

i got backup but how to restore this to another place

1 Like

[For Multi-site]

  • First of all, copy or move other website backup to here : frappe-bench/sites/[sitename]/private/backups
  • So, here we go to: cd /tmp
  • Unzip files from here: gunzip /home/frappe/frappe-bench/sites/[sitename]/private/backups/[database.sql.gz]
  • now back to : cd /home/frappe/frappe-bench/
  • bench --site [sitename] --force restore /home/frappe/frappe-bench/sites/[sitename]/private/backups/[database.sql]

[Note: Don’t forget to remove .gz at hitting final command.]
This might be not a standard approach, but definitely help you, to easy restore of your backups.

4 Likes

thanks for the help

Hi,

Any idea why I get this error? “(2013, ‘Lost connection to MySQL server during query’)”

Its an almost empty site, the sql db backup uncompressed is 8mb, private/public files just 1 jpg.

I run this command to restore DB and its public/private files from the backup created within ERPNext, but it takes something like 20 minutes until the error appears.

Will try to restore manually, restoring db with phpmyadmin and coping the files manually… but would be good to be able to restore with bench commands.

bench --site site1-test.local restore ../DB-Backups/Backups_Manuales/20180318_132828-site1_local-database.sql --with-public-files ../DB-Backups/Backups_Manuales/20180318_132828-site1_local-files.tar --with-private-files ../DB-Backups/Backups_Manuales/20180318_132828-site1_local-private-files.tar

frappe@erpnext:~/frappe-bench$ bench --site site1-test.local restore …/DB-Backups/Backups_Manuales/20180318_132828-site1_local-database.sql --with-public-files …/DB-Backups/Backups_Manuales/20180318_132828-site1_local-files.tar --with-private-files …/DB-Backups/Backups_Manuales/20180318_132828-site1_local-private-files.tar
MySQL root password:
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 94, 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 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, 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 1066, 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 895, 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 535, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 115, in restore
force=context.force)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 65, in _new_site
admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
File “/home/frappe/frappe-bench/apps/frappe/frappe/installer.py”, line 43, in install_db
if not ‘tabDefaultValue’ in frappe.db.get_tables():
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 784, in get_tables
return [d[0] for d in self.sql(“show tables”)]
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 176, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 165, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 321, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1061, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1349, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 991, in _read_packet
packet_header = self._read_bytes(4)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1037, in _read_bytes
CR.CR_SERVER_LOST, “Lost connection to MySQL server during query”)
pymysql.err.OperationalError: (2013, ‘Lost connection to MySQL server during query’)

see new thread here Restore from backup - Lost connection to MySQL server during query?