Error while executing bench backup

following error occurred while doing bench backup

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/maverik/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/maverik/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/maverik/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/home/maverik/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/maverik/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/maverik/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/maverik/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/maverik/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/maverik/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/maverik/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/maverik/frappe-bench/apps/frappe/frappe/commands/site.py”, line 276, in backup
for site in context.sites:
TypeError: ‘NoneType’ object is not iterable

You might not be on the frappe-bench folder while running the bench command

I am in frappe bench folder else the command wont run!

@Ujjawal

I feel you are providing the site name which you intend to backup while executing the command. Backup needs to be executed as follows

  • bench --site site_name backup [--with-files(optional)]

Hope this helps to solve your problem.

I have written the code as follows under frappe-bench directory:

bench --site erpnext.dev backup --with-files

Erpnext.dev is my site name.

Even just trying to execute:

bench --site erpnext.dev

still getting an error.

@Ujjawal

Can you please go to you bench-repo and frappe directory and execute git status.

Since as you stated there should not be any output or it should show message as shown below,

The problem seems to be rare and weird.

Hi shreyas,
The thing is earlier i have been asked by creamdory to execute some commands using git i.e git reset, git pull. And upon doing that i lost all my work and system got reset back to fresh installed erpnext.
So are you sure that it wont reset again?

@Ujjawal

git status is a safe command, it just displays if there is uncommitted work in your directory. So don’t worry this won’t undo any of your changes

maverik@goose:~/bench-repo$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.

nothing to commit, working directory clean

Under bench repo i got the following output executing git status

On executing git status on app erpnext i got the following output:

maverik@goose:~/frappe-bench/apps/erpnext$ git status
On branch develop
Your branch is up-to-date with ‘upstream/develop’.

Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git checkout – …” to discard changes in working directory)

modified:   erpnext/accounts/doctype/account/account.json
modified:   erpnext/accounts/doctype/journal_entry/journal_entry.json
modified:   erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.json
modified:   erpnext/config/hr.py
modified:   erpnext/hr/doctype/appraisal/appraisal.js
modified:   erpnext/hr/doctype/appraisal/appraisal.json
modified:   erpnext/hr/doctype/appraisal/appraisal.py
modified:   erpnext/hr/doctype/attendance/attendance.json
modified:   erpnext/hr/doctype/branch/branch.json
modified:   erpnext/hr/doctype/department/department.json
modified:   erpnext/hr/doctype/designation/designation.json
modified:   erpnext/hr/doctype/employee/employee.js
modified:   erpnext/hr/doctype/employee/employee.json
modified:   erpnext/hr/doctype/employee/employee.py
modified:   erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.json
modified:   erpnext/hr/doctype/employment_type/employment_type.json
modified:   erpnext/hr/doctype/holiday_list/holiday_list.json
modified:   erpnext/hr/doctype/job_applicant/job_applicant.js
modified:   erpnext/hr/doctype/job_applicant/job_applicant.json
modified:   erpnext/hr/doctype/job_applicant/job_applicant.py
modified:   erpnext/hr/doctype/job_opening/job_opening.js
modified:   erpnext/hr/doctype/job_opening/job_opening.json
modified:   erpnext/hr/doctype/job_opening/job_opening.py
modified:   erpnext/hr/doctype/leave_allocation/leave_allocation.json
modified:   erpnext/hr/doctype/leave_application/leave_application.js
modified:   erpnext/hr/doctype/leave_application/leave_application.json
modified:   erpnext/hr/doctype/leave_block_list/leave_block_list.json
modified:   erpnext/hr/doctype/leave_control_panel/leave_control_panel.json
modified:   erpnext/hr/doctype/offer_letter/offer_letter.py
modified:   erpnext/hr/doctype/process_payroll/process_payroll.json
modified:   erpnext/hr/doctype/salary_slip/salary_slip.json
modified:   erpnext/hr/doctype/salary_structure/salary_structure.json
modified:   erpnext/hr/doctype/upload_attendance/upload_attendance.json
modified:   erpnext/setup/doctype/company/company.json
modified:   erpnext/startup/notifications.py

Untracked files:
(use “git add …” to include in what will be committed)

erpnext/hr/doctype/absenteeism/
erpnext/hr/doctype/appraisal_point/
erpnext/hr/doctype/attendee/
erpnext/hr/doctype/disciplinary_action/
erpnext/hr/doctype/employment_type/employment_type.js
erpnext/hr/doctype/family_details/
erpnext/hr/doctype/job_applicant/job_applicant.js~
erpnext/hr/doctype/job_interview/
erpnext/hr/doctype/job_opening/job_opening.js~
erpnext/hr/doctype/joining_document/
erpnext/hr/doctype/kyc_documents/
erpnext/hr/doctype/leave_block_list/leave_block_list.js
erpnext/hr/doctype/post_appraisal_process/
erpnext/hr/doctype/senior_position/
erpnext/hr/doctype/training/

no changes added to commit (use “git add” and/or “git commit -a”)

@Ujjawal

Status for frappe as well

Following is git status for frappe directory.

maverik@goose:~/frappe-bench/apps/frappe$ git status
On branch develop
Your branch is up-to-date with ‘upstream/develop’.

Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git checkout – …” to discard changes in working directory)

modified:   frappe/core/doctype/user/user.json

no changes added to commit (use “git add” and/or “git commit -a”)