# GÓC CÔNG NGHỆ > Hệ điều hành > Linux > English Room >  How to Sync Calendars Between Linux and Android

## nguyentientu4497

How much do you rely on your calendar?

Depending on your productivity methods, it might be a lot. Many of them advocate going completely digital and keeping your schedule in the cloud so that it’s accessible anywhere.

Of course, this requires that all your devices are able to sync with the online calendar. This particular detail often causes worry among new Linux users. They wonder if they can sync their desktop Linux calendars with Android and vice versa.



The short answer is: yes. It’s already possible to remotely control Linux from Android, so there’s no reason why you couldn’t sync calendars. The long answer is that in this article, we explain how to do it and which tools you will need. The diagram below shows the basic idea: you’ll set up a calendar server, create a calendar on it, and connect to it from your Android device(s).



The server can be somewhere “in the cloud” or you can just run it on your computer, in your local network. In that case, you can only sync calendars when your Android devices are connected to that network. This setup relies on the CalDAV protocol that makes it possible to access, manage, and share iCalendar files via HTTP.

While most desktop calendar apps have built-in support for CalDAV, many Android calendars don’t, which is why we need a separate type of app (called CalDAV adapter) to connect to a calendar server.

Now, let’s take it step-by-step, and you’ll soon be able to check your desktop calendar on your Android screen.

*1. Build a Calendar Server*


You can choose any calendar server you want, as long as it supports CalDAV. Since this is an introductory guide, we’ll go with two relatively simple options: Radicale and Baikal. The former is a no-frills solution that requires very little configuration. Baikal might be tricky to set up if you’ve never installed a web server before, but on the other hand, it has a graphical interface through which you can easily tweak it.

*Radicale*


Radicale is available in the repositories of several Linux distributions, including Arch Linux, Ubuntu, Fedora, Debian, and openSUSE. If you want, you can install it from the Python Package Index (PyPi) repository by typing pip install radicale in the terminal.

After the installation, start the server with the command radicale. Note that Radicale needs to be running in order to sync calendars, so make sure to start it every time you work with your desktop calendar app. It might be a good idea to make Radicale run at startup.



The configuration files are /etc/default/radicale, /etc/radicale/users, and /etc/radicale/config or ~/.config/radicale/config. You can just open them in your favorite text editor and uncomment or modify the desired parameters. In order to manage calendars, you’ll have to create a user profile and set the authentication method (check the /etc/radicale/users file for this).

Another important security issue is who can access calendars on the server. You can tweak this setting in the “Rights” section in /etc/radicale/config. Radicale should work out-of-the-box, but if you encounter some problems, refer to the online documentation.



*Baikal*


Compared to Radicale, Baikal is harder to get started with because it requires a web server with PHP and SQLite support. A quick way to set up one such server is to install XAMPP for Linux (also called LAMPP), so you should do that first. The server can reside on your computer and run in the local network if you don’t have a domain and a web-hosting account.

The next step is to download Baikal’s installation package and place its contents into the root document folder of your web server. This is usually the /var/www folder, so you can create a dedicated baikal subfolder there and extract the package into it. Make sure that you have read, write, and execute privileges on the /var/www/baikal/Specific folder and its contents. Create a file called ENABLE_INSTALL in the aforementioned folder. Open your browser and direct it to *http://yourserver/baikal/admin/install*.



Now you can complete the installation, set up the Baikal database, and create an admin account. Don’t forget to tick the box next to the “Enable CalDAV” option, and leave the “Enable Web interface” toggled as well. That way you can create calendars in the browser, so you don’t even need a separate desktop calendar app.



Baikal lets you create multiple users and manage many calendars at once. Just remember that your web server needs to be running in order to use Baikal. Sadly, the official Baikal documentation is not very detailed yet, so you’ll have to resort to various online tutorials if you ever get stuck.

*2. Create a Shared Calendar*


Now that your calendar server is up and running, it’s time to create calendars. If you’re using Baikal, you can do that directly from the web interface. The options are pretty basic, but it lets you add and edit events.



All popular Linux calendar apps support shared (“network”) calendars. To create a new shared calendar in Evolution, open *File > New > Calendar* and choose CalDAV as the calendar type.



In Thunderbird’s Lightning calendar add-on, you can create a shared calendar by selecting *New Calendar > On the Network* and setting CalDAV as the format.



In both cases you’ll have to provide the location or the URL where your shared calendar will be hosted. If you’re using Radicale, enter *http://yourserveraddress:5232/username/calendarname.ics/* or *http://yourserver/cal.php/calendars/username/calendarname* for Baikal.

KDE’s KOrganizer has three options for shared calendars: DAV groupware resource, Calendar in Remote File, and iCal Calendar File. For Radicale, you can choose any of these options and type in the same URL as above. For Baikal, choose *Calendar in Remote File* and enter *http://yourserver/cal.php/calendars/username/calendarname* in both *Download from* and *Upload to* fields.



If you want to add an existing Baikal calendar to KOrganizer, create it as a DAV groupware resource. Skip the login dialog by pressing *Cancel,* and click the *Add* button to make a new server configuration. Select CalDAV as the access protocol, and type in the remote URL for Baikal: *http://yourserver/cal.php/calendars/username/calendarname*.

Similarly, if you already have a desktop calendar that you want to share with Android devices, you can publish it on the calendar server. In Lightning, the option is simply called *Publish Calendar*. Evolution has it under the Actions menu as *Publish Calendar Information*, and in KOrganizer you can choose the *File > Export > Export as iCalendar* option. In all cases the URL you enter should match your username and the calendar filename.

*3. Install a CalDAV Android Adapter*


We suggested two calendar server options, so we’ll keep the Android apps at two as well. Both apps offer a balance between basic and advanced features, and full functionality of advanced options depends on the desktop calendar app you’re using.

*DAVDroid* supports multiple calendars, two-way synchronization, and alongside calendar events, it can also sync tasks. You can adjust the synchronization interval and configure authentication settings. DAVDroid is free on F-Droid, but if you want to support the developers, you can purchase it for $3.61 on Google Play Store.



Another option is *CalDAV-Sync* that also supports multiple user accounts and calendars, tasks, two-way synchronization, and recurring events. CalDAV-Sync lets you color-code your calendars and define a synchronization schedule. You can get it on Play Store for $2.32.

*4. Set Up a CalDAV Account*


If you’ve installed DAVDroid, don’t make the mistake of moving the app to the SD card because it won’t work properly. To sync your shared calendar with Android, open the *Settings* app, choose *Accounts* and add a new DAVDroid account. For Radicale, enter *http://yourserver/username* as Base URL and provide login details. If you’re using Baikal, the Base URL should be *http://yourserver/cal.php*. DAVDroid will automatically detect available calendars, and you can select the ones you want to sync.



The procedure for CalDAV-Sync is nearly identical. Again, go to Android’s Settings, find the Accounts section, and add a new CalDAV account. Radicale users should type in *http://yourserver:5232/username/* and make sure to log in with the same username. CalDAV-Sync will fetch all calendars for that username, so you can choose which ones to sync.



For Baikal, you should input the path to a specific calendar, for example *http://yourserver/cal.php/calendars/username/calendarname*, although the official wiki suggests *http://yourserver[IMG]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAA  l21bKAAAAA1BMVEXh5PJm+yKVAAAAAXRSTlMAQObYZgAAAApJR  EFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=[/IMG]ort/baikal/cal.php/calendars/username/calendarname*. You can try that if the first URL doesn’t work, and you can also try it without the calendar name; CalDAV-Sync will scan for available calendars.

*5. Sync Your Android Calendar App*


Finally, your calendar server is running and you’ve created or shared a calendar on it. On Android, you have a CalDAV adapter and an account all set up. Your calendars should now sync automatically according to their settings. You can check if everything works by opening your Android calendar app.

Although DAVDroid and CalDAV-Sync have been tested with both Baikal and Radicale, problems can always occur. Try this if synchronization doesn’t work:

Check that the Calendar Storage app on Android is not disabled or missing.If you’re using Privacy Guard, this shouldn’t block DAVDroid’s access to calendar and contacts data.Try to disable the Restrict Background Data option in Android’s *Settings > Data Usage.*If your Android device has a system-wide sync switch, make sure it’s not turned off.Due to an Android bug, updating calendar apps can cause CalDAV accounts to get deleted. If this happens, you can install workaround apps for CalDAV-Sync and DAVDroid.
Though it might sound complicated, setting up a calendar server on Linux shouldn’t take longer than 30 minutes. Of course, there are other ways to sync your desktop calendars with Android. You could go with an ownCloud-based solution, manually sync calendars as .ics files, or just use Google Calendar instead of your own calendar server.

If you have any other tips for sharing calendars between Linux and Android, it would be awesome if you left them in the comments. How do you sync your calendars? Which calendar apps do you use? Let us know.

*Image Credits:* 
Computer vector designed by Freepik, KOrganizer screenshot, Baikal screenshots, Calendar icon, Global server icon, Smartphone app icon, Cell phone icon by Freepik from www.flaticon.com.

----------

