2019-02-04 07:20:59 +01:00
|
|
|
---
|
2022-08-19 08:06:51 +02:00
|
|
|
title: How to upgrade borgmatic and Borg
|
2020-08-21 23:27:47 +02:00
|
|
|
eleventyNavigation:
|
2022-08-19 08:06:51 +02:00
|
|
|
key: 📦 Upgrade borgmatic/Borg
|
2020-08-21 23:27:47 +02:00
|
|
|
parent: How-to guides
|
2022-06-17 00:30:53 +02:00
|
|
|
order: 12
|
2019-02-04 07:20:59 +01:00
|
|
|
---
|
2022-08-19 08:06:51 +02:00
|
|
|
## Upgrading borgmatic
|
2019-02-04 07:20:59 +01:00
|
|
|
|
2023-09-05 01:25:10 +02:00
|
|
|
In general, all you should need to do to upgrade borgmatic if you've
|
|
|
|
[installed it with
|
|
|
|
pipx](https://torsion.org/borgmatic/docs/how-to/set-up-backups/#installation)
|
|
|
|
is to run the following:
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
```bash
|
2023-09-05 01:25:10 +02:00
|
|
|
sudo pipx upgrade borgmatic
|
2019-02-04 07:20:59 +01:00
|
|
|
```
|
|
|
|
|
2023-09-05 01:25:10 +02:00
|
|
|
(Or without `sudo` if you installed borgmatic as a non-root user.)
|
|
|
|
|
|
|
|
If you originally installed borgmatic with `sudo pip3 install --user`, you can
|
|
|
|
uninstall it first with `sudo pip3 uninstall borgmatic` and then [install it
|
|
|
|
again with
|
|
|
|
pipx](https://torsion.org/borgmatic/docs/how-to/set-up-backups/#installation),
|
|
|
|
which should better isolate borgmatic from your other Python applications.
|
|
|
|
|
|
|
|
But if you [installed borgmatic without pipx or
|
|
|
|
pip3](https://torsion.org/borgmatic/docs/how-to/set-up-backups/#other-ways-to-install),
|
|
|
|
then your upgrade method may be different.
|
|
|
|
|
2019-11-06 18:31:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
### Upgrading your configuration
|
|
|
|
|
2023-09-05 01:25:10 +02:00
|
|
|
The borgmatic configuration file format is usually backwards-compatible from
|
|
|
|
release to release without any changes, but you may still want to update your
|
|
|
|
configuration file when you upgrade to take advantage of new configuration
|
|
|
|
options or avoid old configuration from eventually becoming unsupported. If
|
|
|
|
you prefer, you can add new configuration options manually.
|
2019-11-06 18:31:00 +01:00
|
|
|
|
|
|
|
If you do want to upgrade your configuration file to include new options, use
|
2023-06-21 21:19:49 +02:00
|
|
|
the `borgmatic config generate` action with its optional `--source` flag that
|
2019-11-06 18:31:00 +01:00
|
|
|
takes the path to your original configuration file. If provided with this
|
2023-06-21 21:19:49 +02:00
|
|
|
path, `borgmatic config generate` merges your original configuration into the
|
2019-11-06 18:31:00 +01:00
|
|
|
generated configuration file, so you get all the newest options and comments.
|
|
|
|
|
|
|
|
Here's an example:
|
|
|
|
|
|
|
|
```bash
|
2023-06-21 21:19:49 +02:00
|
|
|
borgmatic config generate --source config.yaml --destination config-new.yaml
|
2019-11-06 18:31:00 +01:00
|
|
|
```
|
|
|
|
|
2023-06-21 21:19:49 +02:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.7.15</span> The
|
2023-06-21 22:14:54 +02:00
|
|
|
command to generate configuration files was `generate-borgmatic-config`
|
|
|
|
instead of `borgmatic config generate`.
|
2023-06-21 21:19:49 +02:00
|
|
|
|
2019-11-06 18:31:00 +01:00
|
|
|
New options start as commented out, so you can edit the file and decide
|
|
|
|
whether you want to use each one.
|
|
|
|
|
2019-11-12 21:32:32 +01:00
|
|
|
There are a few caveats to this process. First, when generating the new
|
2023-06-21 21:19:49 +02:00
|
|
|
configuration file, `borgmatic config generate` replaces any comments you've
|
2019-11-12 21:32:32 +01:00
|
|
|
written in your original configuration file with the newest generated
|
2019-11-06 18:31:00 +01:00
|
|
|
comments. Second, the script adds back any options you had originally deleted,
|
|
|
|
although it does so with the options commented out. And finally, any YAML
|
|
|
|
includes you've used in the source configuration get flattened out into a
|
|
|
|
single generated file.
|
|
|
|
|
2023-06-21 21:19:49 +02:00
|
|
|
As a safety measure, `borgmatic config generate` refuses to modify
|
2019-11-06 18:31:00 +01:00
|
|
|
configuration files in-place. So it's up to you to review the generated file
|
|
|
|
and, if desired, replace your original configuration file with it.
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
### Upgrading from borgmatic 1.0.x
|
|
|
|
|
|
|
|
borgmatic changed its configuration file format in version 1.1.0 from
|
2023-07-19 08:27:45 +02:00
|
|
|
INI-style to YAML. This better supports validation and has a more natural way
|
2023-09-05 01:25:10 +02:00
|
|
|
to express lists of values. Modern versions of borgmatic no longer include
|
|
|
|
support for upgrading configuration files this old, but feel free to [file a
|
|
|
|
ticket](https://torsion.org/borgmatic/#issues) for help with upgrading any old
|
|
|
|
INI-style configuration files you may have.
|
2019-02-04 07:20:59 +01:00
|
|
|
|
2022-08-19 08:06:51 +02:00
|
|
|
|
|
|
|
## Upgrading Borg
|
|
|
|
|
|
|
|
To upgrade to a new version of Borg, you can generally install a new version
|
|
|
|
the same way you installed the previous version, paying attention to any
|
|
|
|
instructions included with each Borg release changelog linked from the
|
2022-08-22 06:48:37 +02:00
|
|
|
[releases page](https://github.com/borgbackup/borg/releases). Some more major
|
|
|
|
Borg releases require additional steps that borgmatic can help with.
|
2022-08-19 08:06:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
### Borg 1.2 to 2.0
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">New in borgmatic version 1.7.0</span>
|
|
|
|
Upgrading Borg from 1.2 to 2.0 requires manually upgrading your existing Borg
|
|
|
|
1 repositories before use with Borg or borgmatic. Here's how you can
|
|
|
|
accomplish that.
|
|
|
|
|
|
|
|
Start by upgrading borgmatic as described above to at least version 1.7.0 and
|
|
|
|
Borg to 2.0. Then, rename your repository in borgmatic's configuration file to
|
|
|
|
a new repository path. The repository upgrade process does not occur
|
|
|
|
in-place; you'll create a new repository with a copy of your old repository's
|
|
|
|
data.
|
|
|
|
|
|
|
|
Let's say your original borgmatic repository configuration file looks something
|
|
|
|
like this:
|
|
|
|
|
|
|
|
```yaml
|
2023-07-12 04:42:14 +02:00
|
|
|
repositories:
|
|
|
|
- path: original.borg
|
2022-08-19 08:06:51 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Change it to a new (not yet created) repository path:
|
|
|
|
|
|
|
|
```yaml
|
2023-07-12 04:42:14 +02:00
|
|
|
repositories:
|
|
|
|
- path: upgraded.borg
|
2022-08-19 08:06:51 +02:00
|
|
|
```
|
|
|
|
|
2023-07-12 07:10:57 +02:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.8.0</span> This
|
|
|
|
option was found in the `location:` section of your configuration.
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.7.10</span> Omit
|
|
|
|
the `path:` portion of the `repositories` list.
|
|
|
|
|
2022-08-19 08:06:51 +02:00
|
|
|
Then, run the `rcreate` action (formerly `init`) to create that new Borg 2
|
|
|
|
repository:
|
|
|
|
|
|
|
|
```bash
|
2022-10-18 00:04:30 +02:00
|
|
|
borgmatic rcreate --verbosity 1 --encryption repokey-blake2-aes-ocb \
|
2022-08-19 08:06:51 +02:00
|
|
|
--source-repository original.borg --repository upgraded.borg
|
|
|
|
```
|
|
|
|
|
|
|
|
This creates an empty repository and doesn't actually transfer any data yet.
|
|
|
|
The `--source-repository` flag is necessary to reuse key material from your
|
|
|
|
Borg 1 repository so that the subsequent data transfer can work.
|
|
|
|
|
2022-10-18 00:04:30 +02:00
|
|
|
The `--encryption` value above selects the same chunk ID algorithm (`blake2`)
|
2023-02-27 08:22:23 +01:00
|
|
|
commonly used in Borg 1, thereby making deduplication work across transferred
|
|
|
|
archives and new archives.
|
|
|
|
|
|
|
|
If you get an error about "You must keep the same ID hash" from Borg, that
|
|
|
|
means the encryption value you specified doesn't correspond to your source
|
|
|
|
repository's chunk ID algorithm. In that case, try not using `blake2`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
borgmatic rcreate --verbosity 1 --encryption repokey-aes-ocb \
|
|
|
|
--source-repository original.borg --repository upgraded.borg
|
|
|
|
```
|
|
|
|
|
|
|
|
Read about [Borg encryption
|
2023-02-27 01:44:43 +01:00
|
|
|
modes](https://borgbackup.readthedocs.io/en/2.0.0b5/usage/rcreate.html#encryption-mode-tldr)
|
2023-02-27 08:22:23 +01:00
|
|
|
for more details.
|
2022-10-18 00:04:30 +02:00
|
|
|
|
2022-08-19 08:06:51 +02:00
|
|
|
To transfer data from your original Borg 1 repository to your newly created
|
|
|
|
Borg 2 repository:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
borgmatic transfer --verbosity 1 --upgrader From12To20 --source-repository \
|
|
|
|
original.borg --repository upgraded.borg --dry-run
|
|
|
|
borgmatic transfer --verbosity 1 --upgrader From12To20 --source-repository \
|
|
|
|
original.borg --repository upgraded.borg
|
|
|
|
borgmatic transfer --verbosity 1 --upgrader From12To20 --source-repository \
|
|
|
|
original.borg --repository upgraded.borg --dry-run
|
|
|
|
```
|
|
|
|
|
|
|
|
The first command with `--dry-run` tells you what Borg is going to do during
|
|
|
|
the transfer, the second command actually performs the transfer/upgrade (this
|
|
|
|
might take a while), and the final command with `--dry-run` again provides
|
|
|
|
confirmation of success—or tells you if something hasn't been transferred yet.
|
|
|
|
|
|
|
|
Note that by omitting the `--upgrader` flag, you can also do archive transfers
|
2022-12-10 21:59:44 +01:00
|
|
|
between related Borg 2 repositories without upgrading, even down to individual
|
2022-08-19 08:06:51 +02:00
|
|
|
archives. For more on that functionality, see the [Borg transfer
|
2023-02-27 01:44:43 +01:00
|
|
|
documentation](https://borgbackup.readthedocs.io/en/2.0.0b5/usage/transfer.html).
|
2022-08-19 08:06:51 +02:00
|
|
|
|
|
|
|
That's it! Now you can use your new Borg 2 repository as normal with
|
|
|
|
borgmatic. If you've got multiple repositories, repeat the above process for
|
|
|
|
each.
|