Backups: Alternative imports for legacy path (debian 10)
This commit is contained in:
parent
f55c0a68b6
commit
e1aabc4504
2 changed files with 33 additions and 6 deletions
|
@ -12,7 +12,7 @@ import dateutil.parser, dateutil.relativedelta, dateutil.tz
|
||||||
import rtyaml
|
import rtyaml
|
||||||
from exclusiveprocess import Lock, CannotAcquireLock
|
from exclusiveprocess import Lock, CannotAcquireLock
|
||||||
|
|
||||||
from utils import load_environment, shell, wait_for_service, fix_boto, get_php_version
|
from utils import load_environment, shell, wait_for_service, fix_boto, get_php_version, get_os_code
|
||||||
|
|
||||||
rsync_ssh_options = [
|
rsync_ssh_options = [
|
||||||
"--ssh-options= -i /root/.ssh/id_rsa_miab",
|
"--ssh-options= -i /root/.ssh/id_rsa_miab",
|
||||||
|
@ -471,8 +471,20 @@ def list_target_files(config):
|
||||||
|
|
||||||
return [(key.name[len(path):], key.size) for key in bucket.list(prefix=path)]
|
return [(key.name[len(path):], key.size) for key in bucket.list(prefix=path)]
|
||||||
elif target.scheme == 'b2':
|
elif target.scheme == 'b2':
|
||||||
from b2sdk.v1 import InMemoryAccountInfo, B2Api
|
InMemoryAccountInfo = None
|
||||||
from b2sdk.v1.exception import NonExistentBucket
|
B2Api = None
|
||||||
|
NonExistentBucket = None
|
||||||
|
|
||||||
|
if get_os_code() == "Debian10":
|
||||||
|
# WARNING: This is deprecated code using a legacy library.
|
||||||
|
# We need it because Debian 10 ships with an old version of Duplicity
|
||||||
|
from b2.account_info import InMemoryAccountInfo
|
||||||
|
from b2.api import B2Api
|
||||||
|
from b2.exception import NonExistentBucket
|
||||||
|
else:
|
||||||
|
from b2sdk import InMemoryAccountInfo, B2Api
|
||||||
|
from b2sdk import NonExistentBucket
|
||||||
|
|
||||||
info = InMemoryAccountInfo()
|
info = InMemoryAccountInfo()
|
||||||
b2_api = B2Api(info)
|
b2_api = B2Api(info)
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,9 @@ done
|
||||||
# provision free TLS certificates.
|
# provision free TLS certificates.
|
||||||
apt_install duplicity python3-pip python3-gpg virtualenv certbot
|
apt_install duplicity python3-pip python3-gpg virtualenv certbot
|
||||||
|
|
||||||
# b2sdk is used for backblaze backups.
|
|
||||||
# boto is used for amazon aws backups.
|
# boto is used for amazon aws backups.
|
||||||
# Both are installed outside the pipenv, so they can be used by duplicity
|
# Both are installed outside the pipenv, so they can be used by duplicity
|
||||||
hide_output pip3 install --upgrade b2sdk boto
|
hide_output pip3 install --upgrade boto
|
||||||
|
|
||||||
# Create a virtualenv for the installation of Python 3 packages
|
# Create a virtualenv for the installation of Python 3 packages
|
||||||
# used by the management daemon.
|
# used by the management daemon.
|
||||||
|
@ -51,7 +50,23 @@ hide_output $venv/bin/pip install --upgrade \
|
||||||
rtyaml "email_validator>=1.0.0" "exclusiveprocess" \
|
rtyaml "email_validator>=1.0.0" "exclusiveprocess" \
|
||||||
flask dnspython python-dateutil \
|
flask dnspython python-dateutil \
|
||||||
qrcode[pil] pyotp \
|
qrcode[pil] pyotp \
|
||||||
"idna>=2.0.0" "cryptography==2.2.2" boto psutil postfix-mta-sts-resolver b2sdk
|
"idna>=2.0.0" "cryptography==2.2.2" boto psutil postfix-mta-sts-resolver
|
||||||
|
|
||||||
|
# Install backblaze B2 libraries.
|
||||||
|
# Depending on the OS, Duplicity may require different dependencies.
|
||||||
|
case $(get_os_code) in
|
||||||
|
|
||||||
|
$OS_DEBIAN_10)
|
||||||
|
hide_output pip3 install --upgrade "b2<2.0.0"
|
||||||
|
hide_output $venv/bin/pip install --upgrade "b2<2.0.0"
|
||||||
|
;;
|
||||||
|
|
||||||
|
$OS_UBUNTU_2004)
|
||||||
|
hide_output pip3 install --upgrade "b2sdk==1.7.0"
|
||||||
|
hide_output $venv/bin/pip install --upgrade "b2sdk==1.7.0"
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
# Make the venv use the packaged gpgme bindings (the ones pip provides are severely out-of-date)
|
# Make the venv use the packaged gpgme bindings (the ones pip provides are severely out-of-date)
|
||||||
if [ ! -d $venv/lib/python$(python_version)/site-packages/gpg/ ]; then
|
if [ ! -d $venv/lib/python$(python_version)/site-packages/gpg/ ]; then
|
||||||
|
|
Loading…
Reference in a new issue