File: config.rst

package info (click to toggle)
vdirsyncer 0.19.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 980 kB
  • sloc: python: 7,388; makefile: 204; sh: 66
file content (510 lines) | stat: -rw-r--r-- 18,220 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
=========================
Full configuration manual
=========================

Vdirsyncer uses an ini-like format for storing its configuration. All values
are JSON, invalid JSON will get interpreted as string::

    x = "foo"  # String
    x = foo  # Shorthand for same string

    x = 42  # Integer

    x = ["a", "b", "c"]  # List of strings

    x = true  # Boolean
    x = false

    x = null  # Also known as None


.. _general_config:

General Section
===============

::

    [general]
    status_path = ...


- ``status_path``: A directory where vdirsyncer will store some additional data
  for the next sync.

  The data is needed to determine whether a new item means it has been added on
  one side or deleted on the other. Relative paths will be interpreted as
  relative to the configuration file's directory.

  See `A simple synchronization algorithm
  <https://unterwaditzer.net/2016/sync-algorithm.html>`_ for what exactly is in
  there.

.. _pair_config:

Pair Section
============

::

    [pair pair_name]
    a = ...
    b = ...
    #collections = null
    #conflict_resolution = null

- Pair names can consist of any alphanumeric characters and the underscore.

- ``a`` and ``b`` reference the storages to sync by their names.

- ``collections``: A list of collections to synchronize when ``vdirsyncer
  sync`` is executed. See also :ref:`collections_tutorial`.

  The special values ``"from a"`` and ``"from b"``, tell vdirsyncer to try
  autodiscovery on a specific storage. It means all the collections on side A /
  side B.

  If the collection you want to sync doesn't have the same name on each side,
  you may also use a value of the form ``["config_name", "name_a", "name_b"]``.
  This will synchronize the collection ``name_a`` on side A with the collection
  ``name_b`` on side B. The ``config_name`` will be used for representation in
  CLI arguments and logging.

  Examples:

  - ``collections = ["from b", "foo", "bar"]`` makes vdirsyncer synchronize all
    the collections from side B, and also the collections named "foo" and "bar".

  - ``collections = ["from b", "from a"]`` makes vdirsyncer synchronize all
    existing collections on either side.

  - ``collections = [["bar", "bar_a", "bar_b"], "foo"]`` makes vdirsyncer
    synchronize ``bar_a`` from side A with ``bar_b`` from side B, and also
    synchronize ``foo`` on both sides with each other.

- ``conflict_resolution``: Optional, define how conflicts should be handled.  A
  conflict occurs when one item (event, task) changed on both sides since the
  last sync. See also :ref:`conflict_resolution_tutorial`.

  Valid values are:

  - ``null``, where an error is shown and no changes are done.
  - ``"a wins"`` and ``"b wins"``, where the whole item is taken from one side.
  - ``["command", "vimdiff"]``: ``vimdiff <a> <b>`` will be called where
    ``<a>`` and ``<b>`` are temporary files that contain the item of each side
    respectively. The files need to be exactly the same when the command
    returns.

    - ``vimdiff`` can be replaced with any other command. For example, in POSIX
      ``["command", "cp"]`` is equivalent to ``"a wins"``.
    - Additional list items will be forwarded as arguments. For example,
      ``["command", "vimdiff", "--noplugin"]`` runs ``vimdiff --noplugin``.

  Vdirsyncer never attempts to "automatically merge" the two items.

.. _partial_sync_def:

- ``partial_sync``: Assume A is read-only, B not. If you change items on B,
  vdirsyncer can't sync the changes to A. What should happen instead?

  - ``error``: An error is shown.
  - ``ignore``: The change is ignored. However: Events deleted in B still
    reappear if they're updated in A.
  - ``revert`` (default): The change is reverted on next sync.

  See also :ref:`partial_sync_tutorial`.

- ``metadata``: Metadata keys that should be synchronized when ``vdirsyncer
  metasync`` is executed. Example::

      metadata = ["color", "displayname", "description", "order"]

  This synchronizes the following properties:

  - color: ``http://apple.com/ns/ical/:calendar-color``
  - displayname: ``DAV:displayname``
  - description: ``CalDAV:calendar-description`` and ``CardDAV:addressbook-description``
  - order: ``http://apple.com/ns/ical/:calendar-order``

  The ``conflict_resolution`` parameter applies for these properties too.

.. _storage_config:

Storage Section
===============

::

    [storage storage_name]
    type = ...

- Storage names can consist of any alphanumeric characters and the underscore.

- ``type`` defines which kind of storage is defined. See :ref:`storages`.

- ``read_only`` defines whether the storage should be regarded as a read-only
  storage. The value ``true`` means synchronization will discard any changes
  made to the other side. The value ``false`` implies normal 2-way
  synchronization.

- Any further parameters are passed on to the storage class.

.. _storages:

Supported Storages
------------------

CalDAV and CardDAV
++++++++++++++++++

.. note::

    Please also see :ref:`supported-servers`, as some servers may not work
    well.

.. storage:: caldav

    CalDAV.

    ::

        [storage example_for_caldav]
        type = "caldav"
        #start_date = null
        #end_date = null
        #item_types = []
        url = "..."
        #username = ""
        #password = ""
        #verify = /path/to/custom_ca.pem
        #auth = null
        #useragent = "vdirsyncer/0.16.4"
        #verify_fingerprint = null
        #auth_cert = null

    You can set a timerange to synchronize with the parameters ``start_date``
    and ``end_date``. Inside those parameters, you can use any Python
    expression to return a valid :py:class:`datetime.datetime` object. For
    example, the following would synchronize the timerange from one year in the
    past to one year in the future::

        start_date = "datetime.now() - timedelta(days=365)"
        end_date = "datetime.now() + timedelta(days=365)"

    Either both or none have to be specified. The default is to synchronize
    everything.

    You can set ``item_types`` to restrict the *kind of items* you want to
    synchronize. For example, if you want to only synchronize events (but don't
    download any tasks from the server), set ``item_types = ["VEVENT"]``. If
    you want to synchronize events and tasks, but have some ``VJOURNAL`` items
    on the server you don't want to synchronize, use ``item_types = ["VEVENT",
    "VTODO"]``.

    :param start_date: Start date of timerange to show, default -inf.
    :param end_date: End date of timerange to show, default +inf.
    :param item_types: Kind of items to show. The default, the empty list, is
        to show all. This depends on particular features on the server, the
        results are not validated.
    :param url: Base URL or an URL to a calendar.
    :param username: Username for authentication.
    :param password: Password for authentication.
    :param verify: Optional. Local path to a self-signed SSL certificate.
        See :ref:`ssl-tutorial` for more information.
    :param verify_fingerprint: Optional. SHA256 fingerprint of the expected
        server certificate. See :ref:`ssl-tutorial` for more information.
    :param auth: Optional. Either ``basic``, ``digest`` or ``guess``. The
        default is preemptive Basic auth, sending credentials even if server
        didn't request them. This saves from an additional roundtrip per
        request. Consider setting ``guess`` if this causes issues with your
        server.
    :param auth_cert: Optional. Either a path to a certificate with a client
        certificate and the key or a list of paths to the files with them.
    :param useragent: Default ``vdirsyncer``.


.. storage:: carddav

   CardDAV.

   ::

     [storage example_for_carddav]
     type = "carddav"
     url = "..."
     #username = ""
     #password = ""
     #verify = /path/to/custom_ca.pem
     #auth = null
     #useragent = "vdirsyncer/0.16.4"
     #verify_fingerprint = null
     #auth_cert = null
     #use_vcard_4 = false

   :param url: Base URL or an URL to an addressbook.
   :param username: Username for authentication.
   :param password: Password for authentication.
   :param verify: Optional. Local path to a self-signed SSL certificate.
        See :ref:`ssl-tutorial` for more information.
   :param verify_fingerprint: Optional. SHA256 fingerprint of the expected
        server certificate. See :ref:`ssl-tutorial` for more information.
   :param auth: Optional. Either ``basic``, ``digest`` or ``guess``. The
                default is preemptive Basic auth, sending credentials even if
                server didn't request them. This saves from an additional
                roundtrip per request. Consider setting ``guess`` if this
                causes issues with your server.
   :param auth_cert: Optional. Either a path to a certificate with a client
                     certificate and the key or a list of paths to the files
                     with them.
   :param useragent: Default ``vdirsyncer``.
   :param use_vcard_4: Whether the server use vCard 4.0.

Google
++++++

Vdirsyncer supports synchronization with Google calendars with the restriction
that ``VTODO`` files are rejected by the server.

Synchronization with Google contacts is less reliable due to negligence of
Google's CardDAV API. **Google's CardDAV implementation is allegedly a disaster
in terms of data safety**. See `this blog post
<https://evertpot.com/google-carddav-issues/>`_ for the details.  Always back
up your data.

Another caveat is that Google group labels are not synced with vCard's
`CATEGORIES <https://www.rfc-editor.org/rfc/rfc6350#section-6.7.1>`_ property
(also see :gh:`814` and
`upstream issue #36761530 <https://issuetracker.google.com/issues/36761530>`_
for reference) and the
`BDAY <https://www.rfc-editor.org/rfc/rfc6350#section-6.2.5>`_ property is not
synced when only partial date information is present (e.g. the year is missing).

At first run you will be asked to authorize application for Google account
access.

To use this storage type, you need to install some additional dependencies::

    pip install vdirsyncer[google]

Furthermore you need to register vdirsyncer as an application yourself to
obtain ``client_id`` and ``client_secret``, as it is against Google's Terms of
Service to hardcode those into opensource software [googleterms]_:

1. Go to the `Google API Manager <https://console.developers.google.com>`_

2. Create a new project under any name.

2. Within that project, enable the "CalDAV" and "CardDAV" APIs (**not** the
   Calendar and Contacts APIs, those are different and won't work). There should
   be a search box where you can just enter those terms.

3. In the sidebar, select "Credentials", then "Create Credentials" and create a
   new "OAuth Client ID".

   You'll be prompted to create a OAuth consent screen first. Fill out that
   form however you like.

   After setting up the consent screen, finish creating the new "OAuth Client
   ID'. The correct application type is "Desktop application".

4. Finally you should have a Client ID and a Client secret. Provide these in
   your storage config.

The ``token_file`` parameter should be a path to a file where vdirsyncer can
later store authentication-related data. You do not need to create the file
itself or write anything to it.

.. [googleterms] See `ToS <https://developers.google.com/terms/?hl=th>`_,
   section "Confidential Matters".

.. note::

    You need to configure which calendars Google should offer vdirsyncer using
    a secret `settings page
    <https://calendar.google.com/calendar/syncselect>`_.

.. storage:: google_calendar

   Google calendar.

   ::

       [storage example_for_google_calendar]
       type = "google_calendar"
       token_file = "..."
       client_id = "..."
       client_secret = "..."
       #start_date = null
       #end_date = null
       #item_types = []

   Please refer to :storage:`caldav` regarding the ``item_types`` and timerange parameters.

   :param token_file: A filepath where access tokens are stored.
   :param client_id/client_secret: OAuth credentials, obtained from the Google
                                   API Manager.

.. storage:: google_contacts

   Google contacts.

   ::

       [storage example_for_google_contacts]
       type = "google_contacts"
       token_file = "..."
       client_id = "..."
       client_secret = "..."

   :param token_file: A filepath where access tokens are stored.
   :param client_id/client_secret: OAuth credentials, obtained from the Google
                                   API Manager.

The current flow is not ideal, but Google has deprecated the previous APIs used
for this without providing a suitable replacement. See :gh:`975` for discussion
on the topic.

Local
+++++

.. storage:: filesystem

    Saves each item in its own file, given a directory.

    ::

      [storage example_for_filesystem]
      type = "filesystem"
      path = "..."
      fileext = "..."
      #encoding = "utf-8"
      #post_hook = null
      #pre_deletion_hook = null
      #fileignoreext = ".tmp"

    Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
    a more formal description of the format.

    Directories with a leading dot are ignored to make usage of e.g. version
    control easier.

    :param path: Absolute path to a vdir/collection. If this is used in
        combination with the ``collections`` parameter in a pair-section, this
        should point to a directory of vdirs instead.
    :param fileext: The file extension to use (e.g. ``.txt``). Contained in the
        href, so if you change the file extension after a sync, this will
        trigger a re-download of everything (but *should* not cause data-loss
        of any kind). To be compatible with the ``vset`` format you have
        to either use ``.vcf`` or ``.ics``. Note that metasync won't work
        if you use an empty string here.
    :param encoding: File encoding for items, both content and filename.
    :param post_hook: A command to call for each item creation and
        modification. The command will be called with the path of the
        new/updated file.
    :param pre_deletion_hook: A command to call for each item deletion.
        The command will be called with the path of the deleted file.
    :param fileeignoreext: The file extention to ignore. It is only useful
        if fileext is set to the empty string. The default is ``.tmp``.

.. storage:: singlefile

    Save data in single local ``.vcf`` or ``.ics`` file.

    The storage basically guesses how items should be joined in the file.

    .. versionadded:: 0.1.6

    .. note::
        This storage is very slow, and that is unlikely to change. You should
        consider using :storage:`filesystem` if it fits your usecase.

    :param path: The filepath to the file to be written to. If collections are
        used, this should contain ``%s`` as a placeholder for the collection
        name.
    :param encoding: Which encoding the file should use. Defaults to UTF-8.

    Example for syncing with :storage:`caldav`::

        [pair my_calendar]
        a = my_calendar_local
        b = my_calendar_remote
        collections = ["from a", "from b"]

        [storage my_calendar_local]
        type = "singlefile"
        path = ~/.calendars/%s.ics

        [storage my_calendar_remote]
        type = "caldav"
        url = https://caldav.example.org/
        #username =
        #password =

    Example for syncing with :storage:`caldav` using a ``null`` collection::

        [pair my_calendar]
        a = my_calendar_local
        b = my_calendar_remote

        [storage my_calendar_local]
        type = "singlefile"
        path = ~/my_calendar.ics

        [storage my_calendar_remote]
        type = "caldav"
        url = https://caldav.example.org/username/my_calendar/
        #username =
        #password =

Read-only storages
++++++++++++++++++

These storages don't support writing of their items, consequently ``read_only``
is set to ``true`` by default. Changing ``read_only`` to ``false`` on them
leads to an error.

.. storage:: http

    Use a simple ``.ics`` file (or similar) from the web.
    ``webcal://``-calendars are supposed to be used with this, but you have to
    replace ``webcal://`` with ``http://``, or better, ``https://``.

    ::

        [pair holidays]
        a = holidays_local
        b = holidays_remote
        collections = null

        [storage holidays_local]
        type = "filesystem"
        path = ~/.config/vdir/calendars/holidays/
        fileext = .ics

        [storage holidays_remote]
        type = "http"
        url = https://example.com/holidays_from_hicksville.ics

    Too many WebCAL providers generate UIDs of all ``VEVENT``-components
    on-the-fly, i.e. all UIDs change every time the calendar is downloaded.
    This leads many synchronization programs to believe that all events have
    been deleted and new ones created, and accordingly causes a lot of
    unnecessary uploads and deletions on the other side. Vdirsyncer completely
    ignores UIDs coming from :storage:`http` and will replace them with a hash
    of the normalized item content.

    :param url: URL to the ``.ics`` file.
    :param username: Username for authentication.
    :param password: Password for authentication.
    :param verify: Optional. Local path to a self-signed SSL certificate.
        See :ref:`ssl-tutorial` for more information.
    :param verify_fingerprint: Optional. SHA256 fingerprint of the expected
        server certificate. See :ref:`ssl-tutorial` for more information.
    :param auth: Optional. Either ``basic``, ``digest`` or ``guess``. The
        default is preemptive Basic auth, sending credentials even if server
        didn't request them. This saves from an additional roundtrip per
        request. Consider setting ``guess`` if this causes issues with your
        server.
    :param auth_cert: Optional. Either a path to a certificate with a client
        certificate and the key or a list of paths to the files with them.
    :param useragent: Default ``vdirsyncer``.