borg icon indicating copy to clipboard operation
borg copied to clipboard

Interrupted repo initialization creates broken remote repo

Open m3nu opened this issue 6 years ago • 8 comments

Is this a BUG / ISSUE report or a QUESTION?

Bug

System information. For client/server mode post info for both machines.

Linux on the server, macOS on the client. Latest Borg 1.1.8

Full borg commandline that lead to the problem (leave away excludes and passwords)

borg init --encryption=repokey backups.example.com:test-repo

Describe the problem you're observing.

This was reported by BorgBase user Benjamin and successfully reproduced by me: When interrupting the init command at the password prompt, while using a remote repo, a broken repo without Manifest is created and can't be used. Doing the same locally results in no repo at all and the user can try again (expected behavior).

Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

manu@nyx2: ~/Downloads $ borg init --encryption=repokey backups.example.com:test-repo
Enter new passphrase: Connection closed by remote host  # Interrupted with Ctrl-C
manu@nyx2: ~/Downloads $ borg init --encryption=repokey backups.example.com:test-repo
A repository already exists at backups.example.com:test-repo.
manu@nyx2: ~/Downloads $ borg info backups.example.com:test-repo
Repository has no manifest.

Include any warning/errors/backtraces from the system logs

manu@nyx2: ~/Downloads $ borg info --debug backups.example.com:test-repo
using builtin fallback logging configuration
35 self tests completed in 0.11 seconds
SSH command line: ['ssh', 'backups.example.com', 'borg', 'serve', '--umask=077', '--debug']
Remote: using builtin fallback logging configuration
Remote: 35 self tests completed in 0.16 seconds
Remote: using builtin fallback logging configuration
Remote: Initialized logging system for JSON-based protocol
Remote: Resolving repository path b'test-repo'
Remote: Resolved repository path to '/home/manu/test-repo'
Remote: Traceback (most recent call last):

  File "/usr/local/lib/python3.4/dist-packages/borg/remote.py", line 248, in serve
    res = f(**args)

  File "/usr/local/lib/python3.4/dist-packages/borg/repository.py", line 1063, in get
    raise self.ObjectNotFound(id, self.path) from None

borg.repository.ObjectNotFound: Object with key 0000000000000000000000000000000000000000000000000000000000000000 not found in repository /home/manu/test-repo.

RemoteRepository: 182 B bytes sent, 2.45 kB bytes received, 4 messages sent
Repository has no manifest.
Traceback (most recent call last):
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/helpers.py", line 330, in load
    cdata = repository.get(cls.MANIFEST_ID)
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/remote.py", line 924, in get
    for resp in self.get_many([id]):
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/remote.py", line 928, in get_many
    for resp in self.call_many('get', [{'id': id} for id in ids], is_preloaded=is_preloaded):
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/remote.py", line 773, in call_many
    handle_error(unpacked)
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/remote.py", line 750, in handle_error
    raise Repository.ObjectNotFound(args[0].decode(), self.location.orig)
borg.repository.Repository.ObjectNotFound: Object with key 0000000000000000000000000000000000000000000000000000000000000000 not found in repository backups.example.com:test-repo.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/archiver.py", line 4436, in main
    exit_code = archiver.run(args)
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/archiver.py", line 4368, in run
    return set_ec(func(args))
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/archiver.py", line 139, in wrapper
    kwargs['manifest'], kwargs['key'] = Manifest.load(repository, compatibility)
  File "/Users/manu/.pyenv/versions/3.7.1/lib/python3.7/site-packages/borg/helpers.py", line 332, in load
    raise NoManifestError
borg.helpers.NoManifestError: Repository has no manifest.

Platform: Darwin nyx2 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
Borg: 1.1.8  Python: CPython 3.7.1
PID: 64051  CWD: /Users/manu/Downloads
sys.argv: ['/Users/manu/.pyenv/versions/3.7.1/bin/borg', 'info', '--debug', 'backups.example.com:test-repo']
SSH_ORIGINAL_COMMAND: None

manu@nyx2: ~/Downloads $ borg -V
borg 1.1.8

m3nu avatar Jan 13 '19 01:01 m3nu

does borg delete [--force [--force]] work on such a repo?

ThomasWaldmann avatar Jan 13 '19 20:01 ThomasWaldmann

Yes. Works to delete it:

$ borg init --encryption=repokey backups.example.com:test-repo
A repository already exists at backups.example.com:test-repo.

$ borg delete backups.example.com:test-repo
You requested to completely DELETE the repository *including* all archives it may contain.
This repository seems to have no manifest, so we can't tell anything about its contents.
Type 'YES' if you understand this and want to continue: YES

$ borg init --encryption=repokey backups.example.com:test-repo
Enter new passphrase: 

m3nu avatar Jan 14 '19 01:01 m3nu

OK, so while there is some sub-optimal borg behaviour for the remote repo case, there is at least some easy way to clean up again.

ThomasWaldmann avatar Jan 14 '19 01:01 ThomasWaldmann

I just ran into the same issue. I tried to setup borg via Ansible and the command "got stuck" - turned out it waited for the password to be entered and when I interrupted the Ansible script it left me with a halfway setup Borg repo which only showed me Repository has no manifest. as error message.

KevinGimbel avatar Jul 26 '19 13:07 KevinGimbel

I interrupted borg create on its first run and got the Repository has no manifest error.

mconigliaro avatar Feb 06 '20 21:02 mconigliaro

@mconigliaro if you can reproduce this with an up-to-date borg (like 1.1.10 or master branch, if you prefer), please open a separate issue for that.

ThomasWaldmann avatar Feb 09 '20 17:02 ThomasWaldmann

I also created this error because I did CTRL+C when it asked for a passphrase, I did not realize it was asking for the encryption and not asking for the SSH passphrase

williamdes avatar Jul 07 '21 16:07 williamdes

maybe related: #6912

ThomasWaldmann avatar Aug 06 '22 07:08 ThomasWaldmann

I tried to reproduce with current code, with a ssh://... repo and by interrupting at the passphrase prompt (or at the "shall i display your passphrase on screen" prompt):

  • 1.2-maint branch: no repo directory created
  • master branch: no repo directory created

So I guess #6912 really fixed it.

ThomasWaldmann avatar Feb 01 '23 14:02 ThomasWaldmann