: To properly sync with Google-Contacts one would require SyncEvolution version >= 4.99.x.x. Because of vcard interoperability between google-contacts & evolution-data-server, older version of SyncEvolution can not exchange all vcard information properly.
Some new terminology introduced after 4.99.x are used here, but it should also work with older terminology. To know more about new terminology visit here
Introduction
caution: The method described here is applicable for desktop(Unity 7) only. It may not work properly on Ubuntu Touch(Unity 8)
We are going to synchronize google-contacts(Default, Office) with evolution contacts (Personal, Office) respectively.For shake of simplicity we took similar name for these addressbooks.
These following commands are documented assuming one is using the latest version of syncevolution (syncevolution >=1.5.x)
Sync Scenario
Google Contacts |
Evolution Addressbook |
Datastore |
Database |
@Context |
Default |
Personal |
personaladb |
Personal |
gcon |
Office |
Office |
officeadb |
Office |
One can choose any arbitrary peer name. Here we are assuming that the names of the contact lists in google-contacts are "default" & "Office".
Setup
BUG: Ubuntu online account currently suffers from this bug #1433943. As a result one needs to manually add CardDav scope to /usr/share/accounts/services/google-contacts.service. See workaround below here.
Synchronization between Personal & Default addressbook is shown here.
First add a google account with Ubuntu-Online-Account (UOA) OR Gnome-Online-Account (GOA). The username would be like uoa:ACCOUNT_ID,SERVICE_NAME OR goa:YOURUSERNAME@gmail.com for UOA & GOA respectively. If there are multiple accounts with same username (for example: Google & Jabber), acccount-id is used.
Username for, UOA == uoa:ACCOUNT_ID,SERVICE_NAME {OR} UOA == uoa:10,google-contacts
Username for, GOA == goa:YOURUSERNAME@gmail.com {OR} GOA == goa:1687347_526_7
Since UOA & gsso are both based on libgsignond, they will share the same username format. For UOA, to get ACCOUNT_ID users first need to install libaccounts-glib-tools. ACCOUNT_ID can found by running command:
ag-tool list-accounts
It wiil list email-address, provider name & corresponding ACCOUNT_ID...which can be use to find SERVICE_NAME with following command:
ag-tool list-services <ACCOUNT_ID>
For eaxample: ag-tool list-services 9. It will show service type & corresponding SERVICE_NAME. Then one can form username in the required format (i.e uoa:ACCOUNT_ID,SERVICE_NAME). The default SERVICE_NAME for google contacts is google-contacts.
For caldav or carddav sync these services must be enabled. It can be done from Ubuntu-Online-account GUI (settings->online Accounts) {OR} running command in the following format:
ag-tool enable-service <ACCOUNT_ID> <SERVICE_NAME>
Complete information regarding integration with Goa,Uoa/gsso can be found here: http://cgit.freedesktop.org/SyncEvolution/syncevolution/plain/src/backends/signon/README & http://cgit.freedesktop.org/SyncEvolution/syncevolution/plain/src/backends/goa/README
At this point try to run following command to know the remote google contacts database:
syncevolution --print-databases backend=carddav username=uoa:11,google-contacts syncURL=https://www.googleapis.com/.well-known/carddav
If it is successfull the we can proceed with step 1. We will use the required remote database url in step 3.
This username is required in Step1 (For New Methods).
Syncevolution in Ubuntu <=13.10 (from official repo) is NOT compiled with Ubuntu-Online-Account. For UOA, One must compiled syncevolution from source with uoa enabled.For Ubuntu >=14.04 users must install syncevolution-provider-uoa to make it work with Ubuntu-Online-Accounts.
1. Create a Peer for Google calendar (gcon)
When using Ubuntu-Online-Accounts(UOA)
syncevolution --configure --template SyncEvolution username=uoa:ACCOUNT_ID,google-contacts syncURL=https://www.googleapis.com/.well-known/carddav target-config@gcon
Replace ACCOUNT_ID with your own <ACCOUNT_ID> number.
OR
When using Gnome-Online-Accounts(GOA)
syncevolution --configure --template SyncEvolution username=goa:YOURUSERNAME@gmail.com syncURL=https://www.googleapis.com/.well-known/carddav target-config@gcon
If there are multiple accounts of same username it will fail but print account-id in terminal. Next time use that account-id to select a specific google-account.
Here Syncevolution template(which is default template) is used. One can also do it without any template, i.e --template none
2. Create a new datastore for Personal addressbook
syncevolution --configure backend=evolution-contacts database=Personal @default personaladb
This means: in context '@default', create a datastore 'personaladb' (SE knows that we're configuring a data store because we are passing it properties that are relevant to data stores), and on that datastore set the following properties: backend, database
One can use any other name for context (i.e @Local), but those need to be explicitly mentioned in those following steps.
3. Add a remote database to the datastore (personaladb)
syncevolution --configure database=https://www.googleapis.com:443/carddav/v1/principals/YOURUSERNAME%40gmail.com/lists/default/ backend=carddav target-config@gcon personaladb
4. Connect remote calendars with local databases (sync-config)
syncevolution --configure --template SyncEvolution_Client syncURL=local://@gcon username= password= gcon personaladb
Here 'gcon' actually means 'gcon@default' which is implied for the default context only. We can also use any client-endpoint name like .... gconEP personaladb. The client-endpoint name is aslo taken as 'gcon' for the sake of simplicity.
5. Add a local database to the datastore (personaladb)
syncevolution --configure sync=two-way database=Personal gcon personaladb
6. Check whether configured properly (Optional)
To check whether all configuration is working properly one can print all items in local or remote databse.
To print all items(calendar events) in local database run:
syncevolution --print-items gcon personaladb
To print all items(calendar events) in remote database run:
syncevolution --print-items target-config@gcon personaladb
7. Start syncing (First-Time)
syncevolution --sync refresh-from-remote gcon personaladb
For the first-time sync it is strongly recommended to use -- sync refresh-from-remote or --sync slow option during the sync to avoid duplicity.
Caution: "refresh-from-client" option WILL DELETE EVERYTHING IN EVOLUTION CALENDAR (for caldav/carddav client is remote server & server is local client i.e. syncevolution) AND REPLACE WITH GOOGLE-CALENDAR.
To find all possible sync-option run following command at terminal-prompt:
syncevolution --sync ?
General sync-options are explained below:
Sync Option |
Meaning |
two-way |
Normal two-way sync |
slow |
Exchange all data. Recommended for first time sync to avoid duplicity |
refresh-from-remote |
Deletes everything on client & replaces with server |
refresh-from-local |
Deletes everything on server & replaces with client |
refresh-from-client |
Deletes everything on server & replaces with client (opposite for caldav/carddav) |
refresh-from-server |
Deletes everything on client & replaces with server (opposite for caldav/carddav) |
8. Start Normal Sync (After first sync)
syncevolution gcon personaladb
This will start two-way sync which is the default sync-option defined in step 5.
For other calendars repeat steps 2,3,4,5,6 & 7 with separate data-source & remote google contacts databse for each contact-lists/addressbooks. Multiple data-sources can be synced at the same time:
syncevolution gcon personaladb officeadb
To sync all sources under a peer run:
syncevolution gcon
Workaround For Bug #1433943
Install evolution-data-server-online-accounts (Usually it is installed by default)
sudo apt-get install evolution-data-server-online-accounts
Then, first remove any Google-Account you have authorized in UOA. Then run following command:
sudo gedit /usr/share/accounts/services/google-contacts.service
Then add "https://www.googleapis.com/auth/carddav" to <setting type="as" name="Scope"> section. Make sure after adding the scope it will look something like this:
<setting name="ClientSecret">3NbR94RM-DTnA81BWjiJe4TP</setting> <setting type="as" name="Scope">['https://www.googleapis.com/auth/userinfo.email','https://mail.google.com/','https://www.google.com/m8/feeds/','https://www.googleapis.com/auth/calendar','https://www.googleapis.com/auth/carddav']</setting>
Now add a google account & enable calendar & contacts from UOA. Now run following command:
syncevolution --print-databases backend=carddav username=uoa:<Account_ID>,google-contacts syncURL=https://www.googleapis.com/.well-known/carddav
It will fail and ask you to grant permission for evolution. Open UOA, and click grant permission. This will make evolution to get required oauth2 token. Now run the above command again. It should print all the contact databases available. Use that url in Step3 in above setup.
Proceed as described above.