emersion / bups

Simple GUI for Bup, a very efficient backup system.
MIT License
95 stars 8 forks source link

Bups fails backup on linux mint #24

Closed paolodemo closed 7 years ago

paolodemo commented 7 years ago

I setup bups on linux ubuntu, and it was working great. Then I switched to linux mint and when I restarted the backup I obtain this error

Backup started...
Mounting filesystem...
Initializing bup...
Traceback (most recent call last):
  File "/additional/sources/bups/bin/../bups/gtk.py", line 165, in do_backup
    return manager.backup(callbacks)
  File "/additional/sources/bups/bin/../bups/manager.py", line 139, in backup
    "onstatus": lambda line: callbacks["onstatus"](line, ctx)
  File "/additional/sources/bups/bin/../bups/worker.py", line 55, in init
    return self.run(['init'], callbacks)
  File "/additional/sources/bups/bin/../bups/worker.py", line 112, in run
    proc = Popen(args, env=env, stdout=None, stderr=PIPE, universal_newlines=True)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] File o directory non esistente

I have no idea what can be changed. I'm currently using both bups and bup not from the repositories but from git. Can you help me solving the problem?

Thank you for your great job!

emersion commented 7 years ago

It seems that bups cannot find the bup command. Can you check it is in your PATH?

paolodemo commented 7 years ago

bup is in the PATH. I added modify the PATH making the source of a file containing: export PATH="/additional/bin/bin:/additional/sources/bups/bin:$PATH" then:

$ which bup
/additional/bin/bin/bup

I solved adding the environment variable BUP_MAIN_EXE pointing to the bup executable.

I'm not a python developer but maybe the env variable into Popen (worker.py row 112) can overwrite the environment PATH.

emersion commented 7 years ago

Okay, the problem here is that BUP_MAIN_EXE is set automatically to bup when not defined (https://github.com/emersion/bups/blob/master/bups/worker.py#L39), and you have a custom bup install dir. Not sure how to fix that, maybe we could search bup in the PATH instead?

paolodemo commented 7 years ago

I suggested the problem can be the env because I setup this simple test:

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import PIPE, Popen, call
>>> Popen("bup")
<subprocess.Popen object at 0x7f5f4721d210>
>>> Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] <command> [options...]

Common commands:
    fsck       Check backup sets for damage and add redundancy information
    ftp        Browse backup sets using an ftp-like client
    fuse       Mount your backup sets as a filesystem
    help       Print detailed help for the given command
    index      Create or display the index of files to back up
    on         Backup a remote machine to the local one
    restore    Extract files from a backup set
    save       Save files into a backup set (note: run "bup index" first)
    tag        Tag commits for easier access
    web        Launch a web server to examine backup sets

Other available commands:
    bloom                drecurse             import-rsnapshot     ls                   midx                 prune-older          split                                     
    cat-file             gc                   init                 margin               mux                  random               tick                                      
    daemon               import-duplicity     join                 memtest              newliner             rm                   version                                   
    damage               import-rdiff-backup  list-idx             meta                 on--server           server               xstat                                     

See 'bup help COMMAND' for more information on a specific command.

>>> Popen("bup",env={})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
>>> import os
>>> env={}
>>> env['PATH'] = os.environ['PATH']
>>> Popen("bup",env=env)
<subprocess.Popen object at 0x7f5f4721d6d0>
>>> Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] <command> [options...]

Common commands:
    fsck       Check backup sets for damage and add redundancy information
    ftp        Browse backup sets using an ftp-like client
    fuse       Mount your backup sets as a filesystem
    help       Print detailed help for the given command
    index      Create or display the index of files to back up
    on         Backup a remote machine to the local one
    restore    Extract files from a backup set
    save       Save files into a backup set (note: run "bup index" first)
    tag        Tag commits for easier access
    web        Launch a web server to examine backup sets

Other available commands:
    bloom                drecurse             import-rsnapshot     ls                   midx                 prune-older          split                                     
    cat-file             gc                   init                 margin               mux                  random               tick                                      
    daemon               import-duplicity     join                 memtest              newliner             rm                   version                                   
    damage               import-rdiff-backup  list-idx             meta                 on--server           server               xstat                                     

See 'bup help COMMAND' for more information on a specific command.

Popen doesn't fail to find bup in the PATH if called with one argument. Popen fails when empty env is passed, so I think the PATH data is loss. Popen doesn't fail if PATH is into env.

emersion commented 7 years ago

Can you confirm the latest commit fixes the issue?

paolodemo commented 7 years ago

Yes, it's fixed. Many thanks