- Rust-based CLI tool for Zoho to Nextcloud calendar sync - Selective calendar import from Zoho to single Nextcloud calendar - Timezone-aware event handling for next-week synchronization - Comprehensive configuration system with TOML support - CLI interface with debug, list, and sync operations - Complete documentation and example configurations
7.5 KiB
CalDAV Calendar Synchronizer
A Rust-based command-line tool that synchronizes calendar events between Zoho Calendar and Nextcloud via CalDAV protocol. It allows you to selectively import events from specific Zoho calendars into a single Nextcloud calendar.
Features
- Selective Calendar Import: Choose which Zoho calendars to sync from
- Single Target Calendar: All events consolidated into one Nextcloud calendar
- Timezone Support: Handles events across different timezones correctly
- Next Week Focus: Optimized for importing events for the next 7 days
- Simple Data Transfer: Extracts only title, time, and duration as requested
- Secure Authentication: Uses app-specific passwords for security
- Dry Run Mode: Preview what would be synced before making changes
Quick Start
1. Prerequisites
- Rust 1.70+ (for building from source)
- Zoho account with CalDAV access
- Nextcloud instance with CalDAV enabled
- App-specific passwords for both services (recommended)
2. Installation
# Clone the repository
git clone <repository-url>
cd caldavpuller
# Build the project
cargo build --release
# The binary will be at target/release/caldav-sync
3. Configuration
Copy the example configuration file:
cp config/example.toml config/config.toml
Edit config/config.toml with your settings:
# Zoho CalDAV Configuration (Source)
[zoho]
server_url = "https://caldav.zoho.com/caldav"
username = "your-zoho-email@domain.com"
password = "your-zoho-app-password"
# Select which calendars to import
selected_calendars = ["Work Calendar", "Personal Calendar"]
# Nextcloud Configuration (Target)
[nextcloud]
server_url = "https://your-nextcloud-domain.com"
username = "your-nextcloud-username"
password = "your-nextcloud-app-password"
target_calendar = "Imported-Zoho-Events"
create_if_missing = true
4. First Run
Test the configuration with a dry run:
./target/release/caldav-sync --debug --list-events
Perform a one-time sync:
./target/release/caldav-sync --once
Configuration Details
Zoho Setup
-
Enable CalDAV in Zoho:
- Go to Zoho Mail Settings → CalDAV
- Enable CalDAV access
- Generate an app-specific password
-
Find Calendar Names:
./target/release/caldav-sync --list-events --debugThis will show all available calendars.
Nextcloud Setup
-
Enable CalDAV:
- Usually enabled by default
- Access at
https://your-domain.com/remote.php/dav/
-
Generate App Password:
- Go to Settings → Security → App passwords
- Create a new app password for the sync tool
-
Target Calendar:
- The tool can automatically create the target calendar
- Or create it manually in Nextcloud first
Usage
Command Line Options
caldav-sync [OPTIONS]
Options:
-c, --config <CONFIG> Configuration file path [default: config/default.toml]
-s, --server-url <SERVER_URL> CalDAV server URL (overrides config file)
-u, --username <USERNAME> Username for authentication (overrides config file)
-p, --password <PASSWORD> Password for authentication (overrides config file)
--calendar <CALENDAR> Calendar name to sync (overrides config file)
-d, --debug Enable debug logging
--once Perform a one-time sync and exit
--full-resync Force a full resynchronization
--list-events List events and exit
-h, --help Print help
-V, --version Print version
Common Operations
-
List Available Events:
caldav-sync --list-events -
One-Time Sync:
caldav-sync --once -
Full Resynchronization:
caldav-sync --full-resync -
Override Configuration:
caldav-sync --username "user@example.com" --password "app-password" --once
Configuration Reference
Complete Configuration Example
[server]
url = "https://caldav.zoho.com/caldav"
username = "your-email@domain.com"
password = "your-app-password"
timeout = 30
[calendar]
name = "Work Calendar"
color = "#4285F4"
[sync]
sync_interval = 300
sync_on_startup = true
weeks_ahead = 1
dry_run = false
[filters]
exclude_patterns = ["Cancelled:", "BLOCKED"]
min_duration_minutes = 5
max_duration_hours = 24
[logging]
level = "info"
file = "caldav-sync.log"
Environment Variables
You can also use environment variables:
export CALDAV_SERVER_URL="https://caldav.zoho.com/caldav"
export CALDAV_USERNAME="your-email@domain.com"
export CALDAV_PASSWORD="your-app-password"
export CALDAV_CALENDAR="Work Calendar"
./target/release/caldav-sync
Security Considerations
- Use App Passwords: Never use your main account password
- Secure Configuration: Set appropriate file permissions on config files
- SSL/TLS: Always use HTTPS connections
- Log Management: Be careful with debug logs that may contain sensitive data
Troubleshooting
Common Issues
-
Authentication Failures:
- Verify app-specific passwords are correctly set up
- Check that CalDAV is enabled in both services
- Ensure correct server URLs
-
Calendar Not Found:
- Use
--list-eventsto see available calendars - Check calendar name spelling
- Verify permissions
- Use
-
Timezone Issues:
- Events are automatically converted to UTC internally
- Original timezone information is preserved
- Check system timezone if times seem off
-
SSL Certificate Issues:
- Ensure server URLs use HTTPS
- Check if custom certificates need to be configured
Debug Mode
Enable debug logging for troubleshooting:
caldav-sync --debug --list-events
This will show detailed HTTP requests, responses, and processing steps.
Development
Building from Source
# Clone the repository
git clone <repository-url>
cd caldavpuller
# Build in debug mode
cargo build
# Build in release mode
cargo build --release
# Run tests
cargo test
# Check code formatting
cargo fmt --check
# Run linter
cargo clippy
Project Structure
caldavpuller/
├── src/
│ ├── main.rs # CLI interface and entry point
│ ├── lib.rs # Library interface
│ ├── config.rs # Configuration management
│ ├── caldav_client.rs # CalDAV HTTP client
│ ├── event.rs # Event data structures
│ ├── timezone.rs # Timezone handling
│ ├── calendar_filter.rs # Calendar filtering logic
│ ├── sync.rs # Synchronization engine
│ └── error.rs # Error types and handling
├── config/
│ ├── default.toml # Default configuration
│ └── example.toml # Example configuration
├── tests/
│ └── integration_tests.rs # Integration tests
├── Cargo.toml # Rust project configuration
└── README.md # This file
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section above
- Review the debug output with
--debug - Open an issue on the project repository
- Include your configuration (with sensitive data removed) and debug logs