borgmatic-collective / docker-borgmatic

Borgmatic in Docker
GNU General Public License v3.0
341 stars 92 forks source link

Exit status 15 on Borgmatic set up , plus configuration sections being deprecated messages. #348

Closed nodecentral closed 2 weeks ago

nodecentral commented 2 weeks ago

Trying to set up a docker-borgmatic instance and I’ve encountered a few issues, hoping someone can help..

My docker compose is as follows

version: '3'
services:
  borgmatic:
    container_name: borgmatic
    volumes:
        - /home:/mnt/source:ro
        - /share/Container/borg/repository:/mnt/borg-repository
        - /share/Container/borg/.config/borg:/root/.config/borg
        - /share/Container/borg/.ssh:/root/.ssh
        - /share/Container/borg/.cache/borg:/root/.cache/borg
        - /share/Container/borg/borgmatic.d:/etc/borgmatic.d/
    environment:
        - TZ=Europe/London
    image: ghcr.io/borgmatic-collective/borgmatic

My config.ymal is as follows..

source_directories:
    - /mnt/source
repositories:
    - path: /mnt/borg-repository
one_file_system: true

#   Passphase is set in varibable $BORG_PASSPHRASE
#   encryption_passphrase: "DoNotForgetToChangeYourPassphrase"
compression: lz4
archive_name_format: 'backup-{now}'

keep_hourly: 2
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 10

checks:
  - name: repository
    frequency: 2 weeks
  - name: archives
    frequency: always
  - name: extract
    frequency: 2 weeks
  - name: data
    frequency: 1 month

hooks:
    before_backup:
        - echo "Starting a backup job."
    after_backup:
        - echo "Backup created."
    on_error:
        - echo "Error while creating a backup."

before_everything:
    - echo "Starting a backup job."
after_everything:
    - echo "Backup created."
on_error:
    - echo "Error while creating a backup."

# healthchecks:
#     ping_url: ${BORG_HEALTHCHECK_URL}

From there I went in via the docker exec -it borgmatic /bin/sh to run the container for the first time and to do the encryption - see below..

/ # borgmatic init --encryption repokey
/mnt/borg-repository is not a valid repository. Check repo config.
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: Configuration sections (like location:, storage:, retention:, consistency:, and hooks:) are deprecated and support will be removed from a future release. To prepare for this, move your options out of sections to the global scope.
/etc/borgmatic.d/config.yaml: An error occurred
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.

Need some help? https://torsion.org/borgmatic/#issues
/ # borgmatic init --e repokey
/mnt/borg-repository is not a valid repository. Check repo config.
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: Configuration sections (like location:, storage:, retention:, consistency:, and hooks:) are deprecated and support will be removed from a future release. To prepare for this, move your options out of sections to the global scope.
/etc/borgmatic.d/config.yaml: An error occurred
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.

Need some help? https://torsion.org/borgmatic/#issues
/ # exit

It was at this point that I followed some of the guidance within another issue post , which was to update the path in the config.yaml to path: /mnt/borg-repository to path: /mnt/borg-repository/repo (https://github.com/borgmatic-collective/docker-borgmatic/issues/340)

source_directories:
    - /mnt/source
repositories:
    - path: /mnt/borg-repository/repo
one_file_system: true
….

And then I restarted the container and tried again, this time it progress a bit further, but not sure if this is till right, due to the final summary about deprecated support.

[/] # docker restart borgmatic
borgmatic
[/] # docker exec -it borgmatic /bin/sh
/ # borgmatic init --encryption repokey
Repository /mnt/borg-repository/repo does not exist.
Enter new passphrase: 
Enter same passphrase again: 
Do you want your passphrase to be displayed for verification? [yN]: y
Your passphrase (between double-quotes): "ReplaceWithYourSecretPassPhrase"
Make sure the passphrase displayed above is exactly what you wanted.

IMPORTANT: you will need both KEY AND PASSPHRASE to access this repo!

Key storage location depends on the mode:
- repokey modes: key is stored in the repository directory.
- keyfile modes: key is stored in the home directory of this user.

For any mode, you should:
1. Export the borg key and store the result at a safe place:
   borg key export           REPOSITORY encrypted-key-backup
   borg key export --paper   REPOSITORY encrypted-key-backup.txt
   borg key export --qr-html REPOSITORY encrypted-key-backup.html
2. Write down the borg key passphrase and store it at safe place.

summary:
/etc/borgmatic.d/config.yaml: Configuration sections (like location:, storage:, retention:, consistency:, and hooks:) are deprecated and support will be removed from a future release. To prepare for this, move your options out of sections to the global scope.
/ #

How is this looking for people who have done this before ??

witten commented 2 weeks ago

The deprecation warnings are just that—warnings. You should still be able to run borgmatic just fine even with those warnings in place. However if you'd like to future-proof your configuration so that the warnings don't turn into errors in future versions of borgmatic, then you just need to clean up your configuration. In this case, that looks like moving the options out of your hooks: section to the top level and the removing hooks: altogether. Note then that you might have two on_error options so you'd need to pick which one you wanted to keep.

nodecentral commented 2 weeks ago

Many thanks for responding @witten - I removed the entire hooks section , which removes the deprecated messages,

source_directories:
    - /mnt/source
repositories:
    - path: /mnt/borg-repository
one_file_system: true

#   Passphase is set in varibable $BORG_PASSPHRASE
#   encryption_passphrase: "DoNotForgetToChangeYourPassphrase"

compression: lz4
archive_name_format: 'backup-{now}'

keep_hourly: 2
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 10

checks:
  - name: repository
    frequency: 2 weeks
  - name: archives
    frequency: always
  - name: extract
    frequency: 2 weeks
  - name: data
    frequency: 1 month

before_everything:
    - echo "Starting a backup job."
after_everything:
    - echo "Backup created."
on_error:
    - echo "Error while creating a backup."

# healthchecks:
#     ping_url: ${BORG_HEALTHCHECK_URL}

but still gives me the exit status 15 error - is that one of the two on_error you were referring to ?

[~] # docker exec -it borgmatic /bin/sh
/ # borgmatic init --encryption repokey
/mnt/borg-repository is not a valid repository. Check repo config.
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: An error occurred
/mnt/borg-repository: Error running actions for repository
Command '('borg', 'info', '--json', '/mnt/borg-repository')' returned non-zero exit status 15.

Need some help? https://torsion.org/borgmatic/#issues
/ #
witten commented 2 weeks ago

/mnt/borg-repository is not a valid repository. Check repo config.

It looks like somewhere along the way, you must've reverted the "fix" you made above. To re-apply it, change:

repositories:
    - path: /mnt/borg-repository

... to:

repositories:
    - path: /mnt/borg-repository/repo