Skip to main content

A CLI tool to synchronize Obsidian vaults using GitHub.

Project description

Obsidian GitHub Sync

A powerful Python CLI tool to synchronize your Obsidian vaults with GitHub, enabling seamless backup and multi-device sync.

Features

  • ๐Ÿ”„ Automatic Vault Detection: Automatically finds your Obsidian vault on macOS, Windows, and Linux
  • ๐Ÿ“ค Easy Push/Pull: Simple commands to sync your notes with GitHub
  • โฐ Scheduled Sync: Set up automated syncing with your OS's native scheduler
  • ๐Ÿ”’ Secure: Uses Git's proven synchronization technology
  • ๐ŸŒ Cross-Platform: Works on macOS, Windows, and Linux

Prerequisites

  • Python 3.9+: Make sure Python is installed on your system
  • Git: Git must be installed and accessible from your command line
  • GitHub Account: You'll need a GitHub account and repository for storing your vault

Installation

Install the tool via pip:

pip install obsidian-sync

Alternatively, you can install from source:

git clone https://github.com/your-username/obsidian-sync.git
cd obsidian-sync
pip install -e .

Quick Start

1. Create a GitHub Repository

First, create a new, empty repository on GitHub to store your Obsidian vault. You can make it private for security.

2. Initialize Sync

Run the init command to connect your vault to the GitHub repository:

obsidian-sync init --repo-url git@github.com:your-username/your-repo-name.git

The tool will automatically detect your Obsidian vault location. If auto-detection fails, you can specify the path manually:

obsidian-sync init --vault-path "/path/to/your/vault" --repo-url git@github.com:your-username/your-repo-name.git

This command will:

  • Initialize a Git repository in your vault
  • Create a .gitignore file to exclude temporary files
  • Perform the first sync, pushing all your existing notes to GitHub

3. Manual Syncing

Once initialized, you can manually sync your vault at any time:

Push local changes to GitHub:

obsidian-sync push

Pull remote changes from GitHub:

obsidian-sync pull

4. Automated Syncing (Optional)

Set up automatic syncing to run every 15 minutes:

obsidian-sync cron-setup --schedule "*/15 * * * *"

This command will provide you with instructions specific to your operating system:

  • Linux/macOS: Instructions for setting up a cron job
  • Windows: Instructions for setting up a Task Scheduler task

Usage

Commands

init

Initialize a new sync configuration for your Obsidian vault.

obsidian-sync init [OPTIONS]

Options:

  • --vault-path PATH: Path to your Obsidian vault (optional, auto-detected if not provided)
  • --repo-url URL: GitHub repository URL (required)

Examples:

# Auto-detect vault location
obsidian-sync init --repo-url git@github.com:username/vault-backup.git

# Specify vault path manually
obsidian-sync init --vault-path ~/Documents/MyVault --repo-url git@github.com:username/vault-backup.git

push

Push local changes to the remote GitHub repository.

obsidian-sync push [OPTIONS]

Options:

  • --vault-path PATH: Path to your Obsidian vault (optional, uses configured vault if not provided)

Examples:

# Push changes from configured vault
obsidian-sync push

# Push changes from specific vault
obsidian-sync push --vault-path ~/Documents/MyVault

pull

Pull remote changes from GitHub to your local vault.

obsidian-sync pull [OPTIONS]

Options:

  • --vault-path PATH: Path to your Obsidian vault (optional, uses configured vault if not provided)

Examples:

# Pull changes to configured vault
obsidian-sync pull

# Pull changes to specific vault
obsidian-sync pull --vault-path ~/Documents/MyVault

cron-setup

Generate instructions for setting up automated syncing.

obsidian-sync cron-setup [OPTIONS]

Options:

  • --schedule CRON: Cron schedule expression (default: */15 * * * * for every 15 minutes)
  • --vault-path PATH: Path to your Obsidian vault (optional, uses configured vault if not provided)

Examples:

# Set up sync every 15 minutes
obsidian-sync cron-setup --schedule "*/15 * * * *"

# Set up sync every hour
obsidian-sync cron-setup --schedule "0 * * * *"

# Set up sync twice a day (8 AM and 8 PM)
obsidian-sync cron-setup --schedule "0 8,20 * * *"

Cron Schedule Format:

* * * * *
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€ Day of week (0-7, Sunday = 0 or 7)
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€ Month (1-12)
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Day of month (1-31)
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Hour (0-23)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Minute (0-59)

Configuration

The tool stores configuration in ~/.config/obsidian-sync/config.json (Linux/macOS) or %APPDATA%\obsidian-sync\config.json (Windows).

Example configuration:

{
  "vaults": [
    {
      "vault_path": "/Users/jane/Documents/ObsidianVault",
      "repo_url": "git@github.com:jane/obsidian-sync.git",
      "last_sync_time": "2025-12-17T10:00:00Z"
    }
  ]
}

What Gets Synced?

The tool syncs all files in your Obsidian vault, including:

  • โœ… Markdown notes (*.md)
  • โœ… Obsidian settings (.obsidian/ directory)
  • โœ… Plugins and themes
  • โœ… Attachments (images, PDFs, etc.)

Excluded files (via .gitignore):

  • โŒ Workspace layouts (.obsidian/workspace*)
  • โŒ Cache files (.obsidian/cache/)
  • โŒ Trash (.trash/)

Troubleshooting

Vault Not Found

If the tool cannot auto-detect your vault, specify the path manually:

obsidian-sync init --vault-path "/path/to/your/vault" --repo-url <URL>

Git Authentication Issues

If you encounter authentication errors:

  1. SSH: Make sure you have SSH keys set up with GitHub (GitHub SSH Guide)
  2. HTTPS: Use a personal access token instead of your password (GitHub Token Guide)

Merge Conflicts

If you edit the same file on multiple devices without syncing, you may encounter merge conflicts. To resolve:

  1. Navigate to your vault directory
  2. Run git status to see conflicted files
  3. Manually edit the files to resolve conflicts
  4. Run git add . and git commit -m "Resolve conflicts"
  5. Run obsidian-sync push

Development

Running Tests

# Install development dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run unit tests only
pytest tests/unit/

# Run integration tests only
pytest tests/integration/

# Run with coverage
pytest --cov=obsidian_sync

Project Structure

src/
โ”œโ”€โ”€ obsidian_sync/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ main.py              # CLI entry point
โ”‚   โ”œโ”€โ”€ models.py            # Data models
โ”‚   โ”œโ”€โ”€ commands/            # Command implementations
โ”‚   โ”‚   โ”œโ”€โ”€ init.py
โ”‚   โ”‚   โ”œโ”€โ”€ sync.py
โ”‚   โ”‚   โ””โ”€โ”€ schedule.py
โ”‚   โ””โ”€โ”€ logic/               # Core business logic
โ”‚       โ”œโ”€โ”€ git_ops.py       # Git operations
โ”‚       โ””โ”€โ”€ vault.py         # Vault detection
tests/
โ”œโ”€โ”€ unit/                    # Unit tests
โ””โ”€โ”€ integration/             # Integration tests

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Typer for the CLI interface
  • Uses GitPython for Git operations
  • Inspired by the amazing Obsidian note-taking app

Support

If you encounter any issues or have questions:


Happy note-taking! ๐Ÿ“โœจ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obsidian_sync-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obsidian_sync-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file obsidian_sync-0.1.1.tar.gz.

File metadata

  • Download URL: obsidian_sync-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for obsidian_sync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 95f54747eee67193d84e092718774db7e188a26d7c06825fd0cfdd7babdecb85
MD5 19801bc856e1918ba150008d1132f8f6
BLAKE2b-256 6bacc9ace04b6967ff425a636141cd3435c41be19a8c56acefa1ff343b52fbd9

See more details on using hashes here.

File details

Details for the file obsidian_sync-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: obsidian_sync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for obsidian_sync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44b2acd019ad69da3af63bcf91839450163b26e55416fea6c96f67749a2e7a7f
MD5 244e9c9b3fc86f5a3ddca750fa3138b7
BLAKE2b-256 a3297d9c16f9465a5b2f05102ce50960b263f105d805b6b5e526fadd497cc5b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page