Skip to content

Latest commit

 

History

History
387 lines (272 loc) · 6.68 KB

File metadata and controls

387 lines (272 loc) · 6.68 KB

Common Workflows

Practical examples for everyday dotbak usage.


🎯 First Time Setup

Initial Configuration

# Install dotbak
curl -fsSL https://raw.githubusercontent.com/darshithedpara/dotbak/main/install.sh | bash -s -- --yes

# Initialize
dotbak init

# Add your dotfiles (prompts for mode)
dotbak add ~/.zshrc
dotbak add ~/.vimrc
dotbak add ~/.bashrc
dotbak add ~/.config/nvim

# Create first snapshot
dotbak snapshot

# Check everything
dotbak status
dotbak list

📸 Daily Workflow with Snapshots

Morning Routine

# Check current status
dotbak status

# See last snapshot
dotbak snapshot list

Working on Configs

# Edit your configs
vim ~/.zshrc
vim ~/.vimrc

# Test changes...
# Everything working? Create snapshot
dotbak snapshot

# Later in the day, more edits
vim ~/.bashrc

# Create another snapshot
dotbak snapshot --name end-of-day

When Something Breaks

# See available snapshots
dotbak snapshot list

# Compare what changed
dotbak snapshot diff latest

# Restore from working version
dotbak snapshot restore 2025-12-01-090000

# Or restore from named snapshot
dotbak snapshot restore 2025-12-01-120000-before-experiment

🔗 Symlink Mode Workflow

Adding Symlink Files

# Add files that rarely change
dotbak add --symlink ~/.tmux.conf
dotbak add --symlink ~/.gitconfig

# Add directory (choose mode)
dotbak add --symlink ~/.config/alacritty
# Choose [D] for directory symlink or [F] for individual files

Detecting New Files

# Add a new file to symlink-tracked directory
touch ~/.config/alacritty/themes.toml

# Detect it
dotbak symlink-sync

# Found 1 new file:
# ~/.config/alacritty/themes.toml
#   [A]dd / [I]gnore now / i[G]nore always / [Q]uit? a

# ✓ Added to tracking

🚀 Machine Migration

On Old Machine

# Create portable archive
dotbak archive moving-to-new-laptop

# Archive includes EVERYTHING:
# - All config files
# - All snapshots
# - All symlinked files

# Copy archive somewhere safe:
# ~/.dotbak/archives/moving-to-new-laptop.zip

Transfer Archive

Option 1: USB Drive

cp ~/.dotbak/archives/moving-to-new-laptop.zip /media/usb/

Option 2: Cloud

# Upload to Dropbox, Google Drive, etc.

Option 3: Network

rsync ~/.dotbak/archives/moving-to-new-laptop.zip user@new-machine:/tmp/

On New Machine

# Install dotbak
curl -fsSL https://raw.githubusercontent.com/darshithedpara/dotbak/main/install.sh | bash -s -- --yes

# Extract archive
mkdir -p ~/.dotbak
cd ~/.dotbak
unzip /path/to/moving-to-new-laptop.zip

# Deploy everything
dotbak deploy --all --backup

# Done! All your dotfiles are set up:
# - Snapshot files copied from latest snapshot
# - Symlink files symlinked to backups

🧪 Experimenting Safely

Before Making Changes

# Create named snapshot
dotbak snapshot --name before-trying-zsh-plugins

# Try experimental configs
vim ~/.zshrc
# Add new plugins...

# Test it
source ~/.zshrc

# If broken, restore
dotbak snapshot restore before-trying-zsh-plugins

# If it works, create new snapshot
dotbak snapshot --name working-with-plugins

🗂️ Periodic Maintenance

Weekly Cleanup

# Create weekly snapshot
dotbak snapshot --name weekly-$(date +%Y-W%W)

# Clean old snapshots (keep last 10)
dotbak snapshot clean

# Create portable archive for offsite backup
dotbak archive weekly-backup-$(date +%Y-%m-%d)

Monthly Archive

# Create monthly archive for cloud storage
dotbak archive monthly-$(date +%Y-%m)

# Upload to cloud
cp ~/.dotbak/archives/monthly-2025-12.zip ~/Dropbox/backups/

🔧 Before System Upgrade

# Create named snapshot
dotbak snapshot --name before-fedora-42-upgrade

# Create portable archive too (extra safety)
dotbak archive before-fedora-42-upgrade

# Upgrade system...

# If something breaks:
dotbak snapshot restore before-fedora-42-upgrade

# Or full restore from archive if needed
cd ~/.dotbak
rm -rf *
unzip archives/before-fedora-42-upgrade.zip
dotbak deploy --all

📊 Monitoring Changes

Check What Changed

# See diff from latest snapshot
dotbak snapshot diff latest

# Output:
#   ⚠ Changed: ~/.zshrc
#   ✓ No changes: ~/.vimrc

Review Snapshot History

# List all snapshots
dotbak snapshot list

# See details of specific snapshot
dotbak snapshot show 2025-12-01-153803

# Compare two snapshots (manual)
diff ~/.dotbak/snapshots/2025-12-01-090000/.zshrc \
     ~/.dotbak/snapshots/2025-12-01-170000/.zshrc

🎨 Mixed Mode Strategy

Use both modes together for optimal workflow:

# Snapshot mode for files you experiment with
dotbak add --snapshot ~/.zshrc
dotbak add --snapshot ~/.vimrc
dotbak add --snapshot ~/.config/nvim

# Symlink mode for stable configs
dotbak add --symlink ~/.tmux.conf
dotbak add --symlink ~/.gitconfig
dotbak add --symlink ~/.ssh/config

# Daily workflow:
# 1. Edit snapshot-tracked files freely
vim ~/.zshrc

# 2. Create snapshot when satisfied
dotbak snapshot

# 3. Symlink files are auto-backed up
vim ~/.tmux.conf  # Automatically saved!

# 4. Check status
dotbak status

🚨 Emergency Recovery

Full System Crash

If you have your archive:

# On new system
dotbak init
cd ~/.dotbak
unzip /backup/my-dotfiles.zip
dotbak deploy --all --force

Accidentally Deleted File

Snapshot mode:

# Restore from latest snapshot
dotbak snapshot restore latest

Symlink mode:

# File is already in backup!
cd ~/.dotbak/symlinks
ls  # Your file is here

# Or use deploy
dotbak deploy ~/.tmux.conf

📚 Version Control Integration

Using Git with Snapshots

# Track your snapshots with git
cd ~/.dotbak
git init
git add config.toml snapshot.toml symlink.toml
git add snapshots/
git commit -m "My dotfiles - $(date +%Y-%m-%d)"

# Push to GitHub
git remote add origin git@github.com:username/dotfiles.git
git push -u origin main

# On new machine
git clone git@github.com:username/dotfiles.git ~/.dotbak
dotbak deploy --all

🎯 Choosing the Right Mode

Decision Tree

Do you need version history?
  ├─ YES → Use Snapshot Mode
  │         You want to restore old versions
  │
  └─ NO → Use Symlink Mode
            You just want automatic backup

Examples

Snapshot Mode:

  • Shell RC files (.zshrc, .bashrc) - Experiment a lot
  • Editor configs (.vimrc, init.lua) - Try plugins
  • App configs you frequently tweak

Symlink Mode:

  • Git config (.gitconfig) - Rarely changes
  • SSH config (.ssh/config) - Stable
  • Terminal multiplexer (.tmux.conf) - Set and forget

For detailed command reference, see Commands.