一段时间以来,我一直在成功地使用 duplicity 备份到 GCS,但几个月前它停止了工作。我相信迁移到 Python 3 会出现编码问题。我已经看到了一些类似的问题(例如,https ://bugs.launchpad.net/duplicity/+bug/1843995 )声称类似的错误已经解决,但是我仍然得到以下信息:
Traceback (innermost last):
File "/usr/bin/duplicity", line 106, in <module>
with_tempdir(main)
File "/usr/bin/duplicity", line 92, in with_tempdir
fn()
File "/usr/lib/python3/dist-packages/duplicity/dup_main.py", line 1525, in main
action = commandline.ProcessCommandLine(sys.argv[1:])
File "/usr/lib/python3/dist-packages/duplicity/commandline.py", line 1175, in ProcessCommandLine
globals.backend = backend.get_backend(args[0])
File "/usr/lib/python3/dist-packages/duplicity/backend.py", line 225, in get_backend
obj = get_backend_object(url_string)
File "/usr/lib/python3/dist-packages/duplicity/backend.py", line 211, in get_backend_object
return factory(pu)
File "/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py", line 173, in __init__
self.resetConnection()
File "/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py", line 198, in resetConnection
self.bucket = self.conn.create_bucket(self.bucket_name,
File "/usr/lib/python3/dist-packages/boto/gs/connection.py", line 93, in create_bucket
response = self.make_request(
File "/usr/lib/python3/dist-packages/boto/s3/connection.py", line 659, in make_request
auth_path = self.calling_format.build_auth_path(bucket, key)
File "/usr/lib/python3/dist-packages/boto/s3/connection.py", line 94, in build_auth_path
path = '/' + bucket
TypeError: can only concatenate str (not "bytes") to str
您可能没有使用最新的https://launchpad.net/duplicity/+milestone/0.8.14。
自从移植到 python3 以来,已经修复了许多编码错误。
如果您要备份到 S3,还有基于维护的 boto3 模块的新 boto3+s3://。
这里是发布公告中的安装说明(注意首先删除发行版的重复性,如底部建议的那样)
..ede/duply.net
我的方式:
virtualenv --python=/usr/bin/python3 venv/
source venv/bin/activate
git clone git://github.com/boto/boto.git -b develop
value = str(value.encode('utf-8'))
python setup.py install
git clone https://github.com/henrysher/duplicity
cd duplicity
&&python setup.py install