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
.gitignorefile 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:
- SSH: Make sure you have SSH keys set up with GitHub (GitHub SSH Guide)
- 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:
- Navigate to your vault directory
- Run
git statusto see conflicted files - Manually edit the files to resolve conflicts
- Run
git add .andgit commit -m "Resolve conflicts" - 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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:
- ๐ Report a bug
- ๐ก Request a feature
- ๐ Read the documentation
Happy note-taking! ๐โจ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f54747eee67193d84e092718774db7e188a26d7c06825fd0cfdd7babdecb85
|
|
| MD5 |
19801bc856e1918ba150008d1132f8f6
|
|
| BLAKE2b-256 |
6bacc9ace04b6967ff425a636141cd3435c41be19a8c56acefa1ff343b52fbd9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44b2acd019ad69da3af63bcf91839450163b26e55416fea6c96f67749a2e7a7f
|
|
| MD5 |
244e9c9b3fc86f5a3ddca750fa3138b7
|
|
| BLAKE2b-256 |
a3297d9c16f9465a5b2f05102ce50960b263f105d805b6b5e526fadd497cc5b6
|