A powerful Go CLI tool for backing up and restoring project dotfiles with Google Drive synchronization support.
dfsync helps you manage project-specific configuration files (dotfiles) by creating centralized backups in ~/dotfiles/ and maintaining symlinks in your projects. This approach enables seamless synchronization across multiple machines via Google Drive while keeping your projects clean and organized.
- π Smart Backup: Automatically detects and backs up common dotfiles
- π Symlink Management: Creates and manages symlinks transparently
- π Project Organization: Each project gets its own backup folder
- βοΈ Cloud Sync Ready: Designed for Google Drive synchronization
- βοΈ Configurable: Customizable file patterns and backup rules
- π‘οΈ Safe Operations: Validates operations and prevents data loss
git clone https://github.com/heytonyne/dfsync.git
cd dfsync
make installgo install github.com/heytonyne/dfsync/cmd/dfsync@latest-
Initialize dfsync (first time only):
dfsync init
-
Navigate to your project directory:
cd /path/to/your-project -
Backup your dotfiles:
dfsync backup
-
On another machine, restore the dotfiles:
dfsync init # Setup config on new machine cd /path/to/your-project dfsync restore your-project-name
Initialize dfsync configuration (run once per machine)
# Initialize with default settings
dfsync init
# Initialize with custom dotfiles directory
dfsync init --dotfiles-path ~/my-dotfilesBackup current project's dotfiles to ~/dotfiles/
# Basic backup (uses current directory name)
dfsync backup
# Custom backup name
dfsync backup --name my-special-project
# Include additional files
dfsync backup --include "*.secret" --include "custom-config/"
# Force overwrite existing backup
dfsync backup --forceRestore dotfiles from backup to current directory
# Restore specific backup
dfsync restore my-project
# List available backups first
dfsync list
dfsync restore my-projectList all available backups
dfsync listShow current project's backup status
dfsync statusBy default, dfsync backs up these common dotfiles:
.env,.env.local.notes.local,.data.local.augment.vscode/settings.json.idea/(IntelliJ IDEA settings)docker-compose.override.yml*.local.*(any local configuration files)
- Detection: Scans current directory for configured file patterns
- Organization: Creates
~/dotfiles/{project-name}/directory - Migration: Moves detected files to backup location
- Linking: Creates symlinks from backup to original locations
- Metadata: Saves configuration in
.config/config.yml
- Configuration: Reads backup metadata from
.config/config.yml - Validation: Ensures target directory and backup exist
- Cleanup: Removes existing symlinks safely
- Recreation: Creates new symlinks from backup to target
- Update: Records restore timestamp
~/dotfiles/
βββ project-a/
β βββ .config/
β β βββ config.yml # Backup metadata
β βββ .env
β βββ .notes.local
β βββ .vscode/
β βββ settings.json
βββ project-b/
β βββ .config/
β β βββ config.yml
β βββ .env.local
β βββ docker-compose.override.yml
βββ ...
Create ~/.config/dfsync/config.yml:
dotfiles_path: "~/dotfiles"
default_includes:
- ".env"
- ".env.local"
- ".notes.local"
- ".data.local"
- ".augment"
- ".vscode/settings.json"
- ".idea"
- "docker-compose.override.yml"
- "*.local.*"Each backup includes a .config/config.yml file:
name: "my-project"
source_path: "/Users/username/projects/my-project"
backup_path: "/Users/username/dotfiles/my-project"
backup_date: "2024-01-15T10:30:00Z"
files:
- ".env"
- ".notes.local"
directories:
- ".vscode"
symlinks:
- source: "/Users/username/dotfiles/my-project/.env"
target: "/Users/username/projects/my-project/.env"To sync across machines:
- Setup Google Drive: Ensure
~/dotfiles/is in your Google Drive folder (or any other sync providers) - Backup on Machine A: Run
dfsync backupin your project - Wait for Sync: Let Google Drive sync the backup
- Restore on Machine B: Run
dfsync restore project-namein target directory
cd ~/projects/my-webapp
# Creates backup with .env, .vscode/settings.json, etc.
dfsync backup
# On another machine
cd ~/projects/my-webapp
dfsync restore my-webappcd ~/projects/my-go-service
# Include additional configuration
dfsync backup --include ".air.toml" --include "configs/*.local.yml"cd ~/projects/my-project
dfsync status
# Shows: Backed up to ~/dotfiles/my-project (3 files, 1 directory)git clone https://github.com/heytonyne/dfsync.git
cd dfsync
make buildmake testdfsync/
βββ cmd/dfsync/ # CLI entrypoint
βββ internal/ # Private packages
β βββ backup/ # Backup logic
β βββ restore/ # Restore logic
β βββ config/ # Configuration management
β βββ symlink/ # Symlink operations
β βββ utils/ # Utilities
βββ pkg/logger/ # Shared logging
βββ configs/ # Default configurations
βββ docs/ # Documentation
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation
- π Issue Tracker
- π¬ Discussions