Open
Description
I'm looking to find out if import/sync can be done between a unified .vcf
file obtained as export/backup from Google/iCloud/etc.
I presume the singlefile
storage type was created for this, but using a config file: ~/.config/vdirsyncer/config
:
[general]
status_path = "~/.vdirsyncer/status/"
[pair alex_contacts]
a = "contacts_local"
b = "google_backup"
collections = ["from a", "from b"]
metadata = ["color"]
[storage contacts_local]
type = "filesystem"
path = "~/.contacts/"
fileext = ".vcf"
[storage google_backup]
type = "singlefile"
path = "<path to google export of contacts file>.vcf"
Having output:
$ vdirsyncer -v DEBUG discover
Discovering collections for pair alex_contacts
contacts_local:
google_backup:
Saved for alex_contacts: collections = []
vdirsyncer
version: 0.19.1
Server: iCloud/Google export/backup as .vcf
Python version: 3.10.10
OS: arch
Metadata
Metadata
Assignees
Labels
No labels
Activity
azbarcea commentedon Mar 21, 2023
Following docs: config.html?highlight=singlefile#google, and searching for CardDAV, I see
Google Contacts CardDAV API
and People APIIs presume the docs refer to Google Contacts CardDAV API, also known as
contacts-api-migration
. From its documentation:Is the
vdirsyncer
docs still accurate, by supporting Google contacts sync ?WhyNotHugo commentedon Mar 22, 2023
We use the CardDav API: https://developers.google.com/people/carddav
I think that if you had configured something wrong you'd be getting an error, so I don't think you've picked the wrong choice.
Does
vdirsyncer sync
not sync anything? Have you tried commenting usingcollections = null
?azbarcea commentedon Mar 30, 2023
Thank you for your feedback. I'm going to reproduce the issue and post the errors I see.
As alternative to the Google People API CarDAV integration, when the integration doesn't work, I was proposing to support the alternative to sync from a backup file (export) in either
.csv
or.vcf
format, or even for the scenario where one would avoid the hurdle of setting up the integration ... (just a thought)azbarcea commentedon Mar 30, 2023
Setting up Google integration
Running
discover
, it prompts me to the Google page in browser for authentication, after login it will redirect tohttp://127.0.0.1:38437/?state=(...)
and display on the page:Successfully obtained token.
. From terminal:Running with
-vdebug
:This has been executed in a virtualenv:
While
~/.config/vdirsyncer/config
is:azbarcea commentedon Apr 13, 2023
Trying to make it sync with Google Contacts didn't work for me. I'm focused on trying to make it work with
singlefile
option to use it as a source.azbarcea commentedon Apr 20, 2023
Looks to me like the real issue for Google - Local storage to work is documented by #975.
As this issue is not currently fixed, I wonder what you think of the alternative to use the file backup as
singlefile
.azbarcea commentedon Apr 20, 2023
Does anyone knows what the following code in
vdirsyncer/storage/singlefile.py
is supposed to do?path
will be obviously something like/home/user/path/to/latest/backup.vcf
WhyNotHugo commentedon Apr 20, 2023
@azbarcea A storage can have many collections:
%s
in the filename is replaced with thenameid of the collection.You can sync a caldav storage (aka account, which can have multiple calendars) to a singlefile storage (each calendar is one file).
azbarcea commentedon Apr 21, 2023
In short, and maybe this is the real issue, on
python3.v3.10.10
, insinglefile.py
, the line:path_glob = path % "*"
always throws an ExceptionTypeError
and will always fail, even ifpath
is a validos.path
(e.g./home/x/y/z/google.vcf
). After troubleshooting, I realized that althoughpath
was valid, it wasn't extracting thefilename
asstem
.Going to your reply, I presume the purpose of this was to validate that
path
is a valid path. Responding inline:True. A
singlefile
contact storage (as I didn't tested with an.ics
export, as I couldn't find an export from Google of something like that), as I see implemented, has only one collection, and by convention, thecollection
is the same with thename
of the file.The goal is indeed to sync the directory structure:
~/.contacts/{collection1, family, google, etc}
with the google backup/home/x/y/z/google.vcf
Now, maybe there is a problem with
python3
glob
implementation onv3.10.10
, but the way was coded, it would not have replaced thename
/id
of the collection.Now, with a configuration like:
It will extract the
stem
of the path:/home/x/y/z/google.vcf
, which isgoogle
(so it will ignore the extension, so it can match.vcf
or.ics
or just the name of the file without extension (google
is just an example, nothing hardcoded).For
path_glob
to be aglob
type, instead of:maybe should have been:
A more generic example to understand/play with
glob
:As conclusion, the way the PR (#1064) is proposed, per my understanding, satisfies 100% the constraints/requirements you have mentioned above. Because
test/storage/test_singlefile.py
test is failing, I will be following as I understand more ...Any guideline is much appreciated!