KenKundert / emborg

Interactive command line interface to Borg Backup
GNU General Public License v3.0
94 stars 8 forks source link

Emborg commands don't work as expected with a remote borg repo over ssh #41

Closed F0xedb closed 3 years ago

F0xedb commented 3 years ago

Hello,

I've been trying out emborg as a frontend for borg. But it seems like most examples listed in the docs are not working (making it difficult to see archives, restore etc) I ran the following emborg commands:

$ emborg -c test init # created the remote borg repo
$ emborg -c test create

Running Borg create command ...
Checking archive ...
emborg error: no archives are available.
     This error occurred while checking the archives.
    No error was reported while creating the archive.

# emborg can't find the archive created?
$ emborg -c test list

# but borg can?
$ emborg -c test borg list @repo
 serv-2021-03-07T17:23:162021-03-07T17:23:16 Sun, 2021-03-07 17:23:17 [9f42bb5ff2affc23e7ac21dd8550cd2762043e3d27bcd1e113317f05214b247f]
 serv-2021-03-07T17:23:522021-03-07T17:23:52 Sun, 2021-03-07 17:23:53 [8bbab3b27eab798d458b4b9aef9aec6e2a8baf69a375f0e107ad77ae91083a76]
 serv-2021-03-07T17:28:552021-03-07T17:28:55 Sun, 2021-03-07 17:28:56 [560e3a7c630f51b0298543728b3f246899b12d6af914b13e69e4705c538fd255]
 serv-2021-03-07T17:49:232021-03-07T17:49:23 Sun, 2021-03-07 17:49:24 [5810e276481b1020189a0c7218543f203a43d55fad4063f1070c0862bcc6acee]

$ mv test_dir test_dir_2

# because emborg can't find the archive I can't restore it :/
$ emborg -c test restore test_dir
emborg error: no archives are available.

$ emborg version
emborg version: 1.20.0 (2021-02-13) [Python 3.9.2].

It seems that emborg can't find the archives? Even though emborg created them and that borg can find the archives.

Extra info

The test configuration is stored in ~/.config/emborg/test

# Settings for a test configuration
# use of absolute paths is recommended
src_dirs = '/home/zeus/vpn'           # paths to directories to be backed up

The general settings file is stored in ~/.config/emborg/settings And looks as followed (omitting sensitive data)

# These settings are common to all configurations

# configurations
configurations = 'home root test'
default_configuration = 'home'

# encryption
encryption = 'repokey'            # borg encryption method
    # Common choices are 'repokey' and 'keyfile'.
    # With 'repokey' the encryption key is copied into repository, use this
    # only if the remote repository is owned by you and is secure.
    # With 'keyfile' the encryption key is only stored locally. Be sure to
    # export it and save a copy in a safe place, otherwise you may not be
    # able to access your backups if you lose your disk.
# specify either passphrase or avendesora_account
passphrase = '<my_passphrase>'              # passphrase for encryption key

# basic settings
# specify notify if batch and notifier if interactive
notify = '<my_mail>'        # who to notify when things go wrong
notifier = 'notify-send -u normal {prog_name} "{msg}"'
                                         # interactive notifier program
remote_ratelimit = 2000                  # bandwidth limit in kbps
prune_after_create = True                # automatically run prune after a backup
check_after_create = 'latest'            # automatically run check after a backup
show_progress = True

# repository settings
repository = 'backup@<server>:/home/backup/Sync/borg/{host_name}-{user_name}-{config_name}'
prefix = '{host_name}-{{now}}'
compression = 'zstd'

# filter settings
exclude_if_present = '.nobackup'

Any help would be greatly appreciated.

PS: Running any option with the --verbose flag simply prints Running borg <command> command ... and nothing more

F0xedb commented 3 years ago

After some more debugging I found the issue.

It seemed that the prefix and repository didn't match up causing them to not be found The prefix had a -{{now}} part, whilst the repository didn't.

Closing it now

KenKundert commented 3 years ago

The issue is that you included -{{now}} in prefix. That resulted in the prefix changing every time you ran emborg. Since borg ignores archives do not match its prefix, borg ended up ignoring all previously created archives. Just removing the -{{now}} as you did should fix the problem. There should never be a reason to include {{now}} or {{utcnow}} in prefix. I will consider making it illegal. A few more things. --verbose causes emborg to comment on unusual things it sees. Those are pretty rare. If you want the run narrated, use --narrate or view the log file in ~/.local/share/emborg.