multi protocol url suffix

Asked by constantin on 2019-09-10

Hi,

i want to group backups by directory with the multi protocol.

ive got a backup script which for example retrieves a list of databases, exports them and then creates a backup with duplicity.

sftp://backupserver/backup/db/$database

so the url changes depending on the database.

ive used offsite backups only for now but i want to mirror to a local disk therefore switching to multi

i read the documentation and googled but could not find a way to append a suffix to the url.

is there a way i missed ?

otherwise i would like to create a feature request, the implementation should be really easy.

could be implemented with another http get query like this:

duplicity /database/$dbname "multi:///multiconfig.conf?mode=mirror&onfail=continue&urlsuffix=$dbname"

$dbname will be appended to the url value in the json file

Question information

Language:
English Edit question
Status:
Solved
For:
Duplicity Edit question
Assignee:
No assignee Edit question
Solved by:
constantin
Solved:
2019-09-11
Last query:
2019-09-11
Last reply:
constantin (h4r0) said : #1

so i implemented the feature myself but i cant test it because i dont know how to build duplicity

"python setup.py install" doesnt compile the source changes i verified with log output

 "python compilec.py" also doesnt create a binary

can someone help me with this, README* didnt help

constantin (h4r0) said : #2

dunno why but i have to delete the dist.packages folder, now its working

rm -rf /usr/local/lib/python2.7/dist-packages/duplicity
rm /usr/local/bin/duplicity
python setup.py install

constantin (h4r0) said : #3

tested everything and it works fine.

here is my patch

#sub path patch
cat << 'EOP' | git -C duplicity/backends apply
diff --git a/multibackend.py b/multibackend.py
index 27ffa0a..58d4f51 100644
--- a/multibackend.py
+++ b/multibackend.py
@@ -50,6 +50,7 @@ class MultiBackend(duplicity.backend.Backend):
     __knownQueryParameters = frozenset([
         u'mode',
         u'onfail',
+ u'subpath',
     ])

     # the mode of operation to follow
@@ -70,6 +71,10 @@ class MultiBackend(duplicity.backend.Backend):
         u'continue',
     ])

+ # sub path to dynamically add sub directories to backends
+ # will be appended to the url value
+ __subpath = u''
+
     # when we write in stripe mode, we "stripe" via a simple round-robin across
     # remote stores. It's hard to get too much more sophisticated
     # since we can't rely on the backend to give us any useful meta
@@ -159,6 +164,9 @@ class MultiBackend(duplicity.backend.Backend):
                     % (u'onfail', self.__onfail_mode), log.ERROR)
             raise BackendException(u"MultiBackend: invalid onfail value")

+ if u'subpath' in queryParams:
+ self.__subpath = queryParams[u'subpath']
+
         try:
             with open(parsed_url.path) as f:
                 configs = json.load(f)
@@ -173,7 +181,7 @@ class MultiBackend(duplicity.backend.Backend):
             raise BackendException(u'Could not load config file')

         for config in configs:
- url = config[u'url']
+ url = config[u'url'] + self.__subpath
             # Fix advised in bug #1471795
             url = url.encode(u'utf-8')
             log.Log(_(u"MultiBackend: use store %s")
EOP

Thanks for the patch! All help is welcome!