Error restoring or creating new site

[Installation: frappe 7.0.35, erpnext 7.0.48, easy install on brand-new clean install of Ubuntu 16.04.1 minimal on VPS]

After following easy-install instructions, the first thing I tried to do was restore from backup (from a different VPS) following the instructions here:

home/frappe/frappe-bench$ bench --site my.sitename.com --force restore /tmp/20160921_17272161_database.sql
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 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/__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 97, in restore
    frappe.init(site=site)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 121, in init
    local.conf = _dict(get_site_config())
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 175, in get_site_config
    raise IncorrectSitePath, "{0} does not exist".format(site_config)
frappe.exceptions.IncorrectSitePath: 404: Not Found```

So then I tried to create my.sitename.com and got a permission denied error:

```/home/frappe/frappe-bench$ bench new-site my.sitename.com
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 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/apps/frappe/frappe/commands/site.py", line 26, in new_site
    verbose=verbose, install_apps=install_app, source_sql=source_sql, force=force)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 50, in _new_site
    make_site_dirs()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 321, in make_site_dirs
    os.makedirs(dir_path)
  File "/home/frappe/frappe-bench/env/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/frappe/frappe-bench/env/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/frappe/frappe-bench/env/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: './my.sitename.com'

The user executing the command must have permission to clear folders on the frappe-bench folder

Thanks @rmehta. So should I sudo it? Or can you please explain how to set those permissions?

sudo may not be the answer as always, it might mess up your file permissions and you will need to manually correct it afterwards.

Please Google before you ask generic or unrelated questions here or care to read forum for other similar replies on the issue.

If after doing a standard easy install the permissions are not correct, it seems entirely relevant, to me, to ask how to set them right in this context. Sure I can find methods in Google but this is directly related to correcting installer behavior.

So I did Google it. What I did was:

sudo usermod -a -G frappe myUserName

That didn’t solve the problem. So then I also tried:

sudo find /home/frappe -type d -exec chmod 2775 {} \;
sudo find /home/frappe -type f -exec chmod ug+rw {} \;````

After trying to restore again, I got the same error. If you do know the solution, please share your knowledge.

@PeterDF Its not just your users permissions, there are some packages paths with permission issue.

Next time you do your setup please copy entire console output and run installer with debug mode on (verbose) and share it via pastebin or similar service here.
That only will help us to find out what really went wrong in your case.

I have been trying for days now to restore from backup to a new server. I have Googled. I have read docs. I keep getting errors. Here is the latest output on a fresh Ubuntu install.

Pastebin of output

Make sure to run your bench commands from specific bench home directory!

As you can run/install multiple bench home in same machine now, changing to specific directory is only way you can access bench functions & utilities in particular.

If you have performed auto installation, then your bench home directory would be frappe-bench/ under user frappe in path /home/frappe/frappe-bench/

Specifically in your case:

$ cd /home/frappe/frappe-bench/
$ bench --site server.domain.com restore --force /tmp/20161010_65197541_database.sql.gz --with-private-files /tmp/20161010_65197541_private_files.tar --with-public-files /tmp/20161010_65197541_files.tar
Error: no such option: --force
myusername@server:/home/frappe/frappe-bench$ bench --site server.domain.com restore /tmp/20161010_65197541_database.sql.gz --with-private-files /tmp/20161010_65197541_private_files.tar --with-public-files /tmp/20161010_65197541_files.tar
/tmp/20161010_65197541_database.sql.gz:    gzip: /tmp/20161010_65197541_database.sql.gz: Operation not permitted
 75.4% -- replaced with /tmp/20161010_65197541_database.sql
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/__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 94, in restore
    sql_file_path = extract_sql_gzip(os.path.abspath(sql_file_path))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 367, in extract_sql_gzip
    subprocess.check_call(['gzip', '-d', '-v', '-f', sql_gz_path])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[u'gzip', u'-d', u'-v', u'-f', u'/tmp/20161010_65197541_database.sql.gz']' returned non-zero exit status 2
myusername@server:/home/frappe/frappe-bench$ ```

Should I first follow the instructions for setting up a site (normal first-time production setup) before running the restore command?