Skip to content

Instantly share code, notes, and snippets.

@antoinedelia
Last active November 16, 2025 16:58
Show Gist options
  • Select an option

  • Save antoinedelia/b33e2fe8a5492c642e02d6976401c1a4 to your computer and use it in GitHub Desktop.

Select an option

Save antoinedelia/b33e2fe8a5492c642e02d6976401c1a4 to your computer and use it in GitHub Desktop.
Rsync from NAS to external drive using WSL

Rsync from NAS to external drive using WSL

Prerequisites:

sudo apt update
sudo apt install cifs-utils

If the hard drive was connected after WSL was launched:

# Using Powershell
wsl --shutdown

# Then, reopen a WSL terminal, and confirm files are present
ls /mnt/d

Getting Started

In WSL:

Create a mount point:

sudo mkdir -p /mnt/nas_drive

Store your NAS login

sudo nano ~/.smbcredentials
username=your_nas_username
password=your_nas_password

Secure it:

chmod 600 ~/.smbcredentials

Mount it:

# If it fails because of the hostname, use the IP or run the command below
# echo "192.168.1.22 Antoine-NAS" | sudo tee -a /etc/hosts
sudo mount -t cifs //Antoine-NAS/drive /mnt/nas_drive -o credentials=/home/$USER/.smbcredentials,vers=3.0

Verify the mount:

df -h | grep nas_drive
ls /mnt/nas_drive

Automatically mount each time:

sudo nano /etc/fstab
//192.168.1.22/drive /mnt/nas_drive cifs credentials=/home/USERNAME/.smbcredentials,vers=3.0,iocharset=utf8,nofail 0 0

Rsync:

# Dry-run first, let's be safe
rsync -avz --delete --progress --dry-run /mnt/nas_drive/ /mnt/d/nas-backups/drive/

# Now for the real deal
rsync -avz --delete --progress /mnt/nas_drive/ /mnt/d/nas-backups/drive/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment