Fix remote repo init
This commit is contained in:
parent
5ed6bd51fb
commit
4f98c40b15
2 changed files with 6 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ To adhere to the [3-2-1 backup rule](https://en.wikipedia.org/wiki/Backup) witho
|
|||
|
||||
The [`docker-compose.yml`](docker-compose.yml) file demonstrates how to set up multiple backup targets using environment variables such as `BORG_REPO_0`, `BORG_REPO_1`, `BORG_PASSPHRASE_0`, `BORG_PASSPHRASE_1`, and so forth. The backup script sequentially handles each repository defined by the environment variables, ensuring your source volume is backed up across all specified targets.
|
||||
|
||||
Missing repositories are initialized automatically. An existing local directory, including the `/local-backup` bind mount, is initialized only after confirming that it is empty (including hidden files). Invalid or inaccessible repositories are rejected.
|
||||
Missing repositories are initialized automatically. Existing directories, both local (including the `/local-backup` bind mount) and over SSH, are initialized only after Borg confirms that they are empty (including hidden files). Invalid or inaccessible repositories are rejected.
|
||||
|
||||
The backup script first takes `BORG_REPO_0` and the corresponding env vars and sets up the [`BORG_REPO`](https://borgbackup.readthedocs.io/en/stable/usage/general.html#repository-urls), `BORG_REMOTE_PATH`, and `BORG_PASSPHRASE` environment variables for `borg`. Once the backup finished (successfully or otherwise), the script checks whether `BORG_REPO_1` exists, if so, it sets `BORG_REPO` and the other env vars to their expected values and backs up again. The script keeps going to `BORG_REPO_2`, `BORG_REPO_3` and so on as long as these are set. It then checks each repository with the corresponding environment before starting the next backup cycle.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ borg_ensure_repository() {
|
|||
local status=0
|
||||
borg_wait info || status=$?
|
||||
(( status != 0 )) || return 0
|
||||
if (( status == 13 )) || (( status == 15 )); then
|
||||
echo 'Repository is missing or confirmed empty. Initializing Borg...'
|
||||
# Borg 1.4 reports InvalidRepository over SSH as generic RPC exit code 2,
|
||||
# even with modern exit codes enabled. Let init validate the destination:
|
||||
# it accepts missing/empty directories and refuses existing data.
|
||||
if (( status == 2 || status == 13 || status == 15 )); then
|
||||
echo 'Repository could not be opened. Attempting Borg initialization...'
|
||||
status=0
|
||||
borg_wait init --encryption=repokey || status=$?
|
||||
# Another client may have initialized it after the initial check.
|
||||
|
|
|
|||
Loading…
Reference in a new issue