README
1= How to write a backend, in five easy steps! =
2
3There are five main methods you want to implement:
4
5__init__ - Initial setup
6_get
7 - Get one file
8 - Retried if an exception is thrown
9_put
10 - Upload one file
11 - Retried if an exception is thrown
12_list
13 - List all files in the backend
14 - Return a list of filenames
15 - Retried if an exception is thrown
16_delete
17 - Delete one file
18 - Retried if an exception is thrown
19
20There are other methods you may optionally implement:
21
22_delete_list
23 - Delete list of files
24 - This is used in preference of _delete if defined
25 - Must gracefully handle individual file errors itself
26 - Retried if an exception is thrown
27_query
28 - Query metadata of one file
29 - Return a dict with a 'size' key, and a file size value (-1 for not found)
30 - Retried if an exception is thrown
31_query_list
32 - Query metadata of a list of files
33 - Return a dict of filenames mapping to a dict with a 'size' key,
34 and a file size value (-1 for not found)
35 - This is used in preference of _query if defined
36 - Must gracefully handle individual file errors itself
37 - Retried if an exception is thrown
38_retry_cleanup
39 - If the backend wants to do any bookkeeping or connection resetting inbetween
40 retries, do it here.
41_error_code
42 - Passed an exception thrown by your backend, return a log.ErrorCode that
43 corresponds to that exception
44_move
45 - If your backend can more optimally move a local file into its backend,
46 implement this. If it's not implemented or returns False, _put will be
47 called instead (and duplicity will delete the source file after).
48 - Retried if an exception is thrown
49_close
50 - If your backend needs to clean up after itself, do that here.
51
52== Subclassing ==
53
54Always subclass from duplicity.backend.Backend
55
56== Registering ==
57
58You can register your class as a single backend like so:
59
60duplicity.backend.register_backend("foo", FooBackend)
61
62This will allow a URL like so: foo://hostname/path
63
64Or you can register your class as a meta backend like so:
65duplicity.backend.register_backend_prefix("bar", BarBackend)
66
67Which will allow a URL like so: bar+foo://hostname/path and your class will
68be passed the inner URL to either interpret how you like or create a new
69inner backend instance with duplicity.backend.get_backend_object(url).
70
71== Naming ==
72
73Any method that duplicity calls will start with one underscore. Please use
74zero or two underscores in your method names to avoid conflicts.
75
76== Testing ==
77
78Use "./testing/manual/backendtest foo://hostname/path" to test your new
79backend. It will load your backend from your current branch.
80