On friday all hosts that had B2 as a endpoint for Duplicity failed with error “Authtoken expired, will reauthenticate with next attempt”.
I still have no idea what has changed, but lets fix it.
In this article we will upgrade Duplicity and install B2 via pip (package), as from version 0.15 of Duplicity that is necessary.
You are in luck, just need to grab the latest Duplicity version from backports. Enable backports by the usual instructions. Be careful if you have some repositories pinned.
apt-get -t stretch-backports install duplicity
The B2 access has changed in version 0.15, so you need to install the B2 libraries via pip.
pip install b2
Problem with the pip way is that it pulls a lot of packages that we don’t necessarily want on the production server. We can avoid that by installing the B2 Python stuff by hand.
If you don’t want pip, do:
wget https://files.pythonhosted.org/packages/21/3f/2ca1d3d3990b044549c26c0a0c5797bb1231709f8ce808caad1e8b4fcb70/b2-1.1.0.tar.gz
tar xvfz b2-1.1.0.tar.gz
cd b2-1.1.0
python setup.py install
If you are missing the module named setuptools, or get this error:
raise BadDateFormat(server_date_str)
BadDateFormat: Date from server: Tue, 19 Jun 2018 08:44:46 GMT
Install/upgrade the package:
apt-get install python-setuptools
Debian Jessie users have a little less luck, as the latest Duplicity version, even in backports is very old.
To solve this issue we can blatantly steal Ubuntu packages and incorporate them in our system.
Create the file:
vim /etc/apt/sources.list.d/duplicity.list
And add the following content
deb http://ppa.launchpad.net/duplicity-team/ppa/ubuntu trusty main
deb-src http://ppa.launchpad.net/duplicity-team/ppa/ubuntu trusty main
Update the repository cache:
apt-get update
Check what will be done:
apt-get --recon install duplicity
Update Duplicity:
apt-get install duplicity
Ignore the trust issues and proceed with install.
And install B2 as before.
You should really upgrade the server… Better hit yourself in the knee… But if you insist…
Install latest duplicity from source, obtain the latest file:
wget https://code.launchpad.net/duplicity/0.7-series/0.7.17/+download/duplicity-0.7.17.tar.gz
tar xvfz duplicity-0.7.17.tar.gz
cd duplicity-0.7.17
python setup.py install
As this was a machine where Duplicity was already present there were no drama. Maybe if you are doing a clean install, some dependencies will come to surface, but unfortunatly they are outside of the scope of this mini writeup.
Enter the hole of fixing B2 dependencies by hand.
You need to install:
Last two packages were tricky, if you get stuck and get:
BackendException: B2 backend requires B2 Python APIs (pip install b2)
You can partially debug the thing by trying to import B2 stuff into a Python interpreter:
$ python
Python 2.7.3 (default, Jun 21 2016, 18:38:19)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import b2
>>> import b2.api
>>>
If you get errors, go and fetch the missing packages…
wget the latest version, untar, python setup.py install
And finally install the B2 as for Jessie.
apt-get install -y python-setuptools
apt-get install python-backports.functools-lru-cache
Add this:
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf