Fundamentals 4 min read

Complete Guide: Setting Up a Full-Stack WSL2 Development Environment with Automated Backups

This article walks through building a robust WSL2 development environment on Windows, covering an automated PowerShell backup script, Zsh + Oh My Zsh + Powerlevel10k terminal customization, and the installation of Python (using uv), Go, Node (via nvm), and Java (via SDKMAN!), plus best‑practice workspace organization.

Tinker Programmer
Tinker Programmer
Tinker Programmer
Complete Guide: Setting Up a Full-Stack WSL2 Development Environment with Automated Backups

Automated Backup for WSL2

The author provides a PowerShell script ( # backup-wsl.ps1 core logic) that exports the Ubuntu distribution to a timestamped .tar file, stores it in D:\wsl-backup, and automatically removes older archives, keeping only the five most recent versions. The script can be scheduled with Windows Task Scheduler to run weekly, ensuring the environment can be restored without data loss.

# backup-wsl.ps1 core logic
$backupPath = "D:\wsl-backup"
$date = Get-Date -Format "yyyy-MM-dd_HH-mm"

# Export Ubuntu distribution
wsl --export Ubuntu "$backupPath\ubuntu-$date.tar"

# Keep only the latest 5 backups
Get-ChildItem $backupPath -Filter "*.tar" |
  Sort-Object LastWriteTime -Descending |
  Select-Object -Skip 5 | Remove-Item

Restoration is straightforward: unregister the existing Ubuntu instance with wsl --unregister Ubuntu and then import the desired backup using wsl --import, which restores the environment in minutes.

Terminal Beautification with Zsh and Powerlevel10k

To replace the default Bash prompt, the guide installs Zsh, sets it as the default shell, and adds Oh My Zsh together with the Powerlevel10k theme for an enhanced visual experience.

# Install Zsh and set as default shell
sudo apt install -y zsh
chsh -s $(which zsh)

# One‑click installation of Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

A warning highlights a potential plugin conflict: zsh-autocomplete overlaps with zsh-autosuggestions. The author recommends using only one of them, preferring zsh-autosuggestions.

Python Environment Using uv

Instead of the traditional pip or conda, the article suggests uv for faster package installation and cleaner project isolation. Installation is performed via a curl script, and a Chinese mirror (Tsinghua University) is configured for accelerated downloads.

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Use Tsinghua mirror in China
export UV_DEFAULT_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple"

Additional Language Setups and Workspace Practices

The guide also covers complete installation and configuration steps for Go, Node (using nvm), and Java (using SDKMAN!), as well as recommended directory structures for organizing projects. Detailed notes, including all commands and troubleshooting tips, are linked to the original article.

Reference Links

The full configuration notebook, containing every code snippet and pitfall explanation, is available in the original post on the publishing platform.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

development environmentZshPowerShelluvWSL2
Tinker Programmer
Written by

Tinker Programmer

Solving problems with code, sharing practical tech insights, and leveling up together!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.