[TUTORIAL] ZFS SEND snapshot from inside Windows to Proxmox ZFS with SSH

v95klima

Member
Jun 24, 2022
80
9
13
In Homelab (this is beta zfs in windows, with risks):
since family members use windows and I use ZFS on Proxmox host for NAS, this solution has been wanted, and after fair amount of testing, got it to work.

First add an extra virtual or physical hardrive Windows VM or Windows bare metal, for the ZFS file system.
When I add as virtual disk to Win VM I used bus device SCSI and RAW file format.

Then in Windows OS installed from
https://github.com/openzfsonwindows/openzfs
the exe file
https://github.com/openzfsonwindows...-2.2.3rc5/OpenZFSOnWindows-debug-2.2.3rc6.exe
# Go through installation, accepting the question of adding to PATH when prompted

# then per https://openzfsonosx.org/wiki/Windows_pool
# List Disks available
wmic diskdrive list brief
# if second disk not visible use windows Disk Management to mount/enable second new added disk and try listing discs with wmic again.

# Create pool on second newly added disk (called "disk 1" in my case, disk 0 is windows OS install ) named tank (or other name).
zpool.exe create -O casesensitivity=insensitive -O normalization=formD -O compression=lz4 -O atime=off -o ashift=12 tank PHYSICALDRIVE1

#then do:
zpool.exe import
# should now see pool named tank (or other chosen name).
zpool.exe import tank
# then as normal, but with .exe
zfs.exe create tank/data

# recommend not mounting on separate drive (automatically shows up and D: or E: as default) by following this
https://openzfsonosx.org/wiki/Windows_driveletter
zfs set driveletter=off tank
zpool export tank
zpool import tank
zfs mount tank
# it is now usable at c:\tank\data

You will now have full ZFS functionality just remember to use .exe, incl making snapshots.
zfs.exe send / receive works locally on windows between diffrent data mounts or between local pools if you have more than one pool, with 2.2.3rc6.exe

Install ssh.exe on windows. (google as needed how)
Setup ssh-keygen.exe without password prompt logged in as as Administrator.

Upload the key to Proxmox server and make the server accept ssh login with keys. test ssh.exe login works as planned with no password prompt.
Now I really wanted the ability send through SSH the local win snapshots to Proxmox. The way to do that is WSL.

in Powershell, run as admin per the following:
https://learn.microsoft.com/en-us/windows/wsl/install
wsl --install
reboot
then
wsl --install -d <DistroName>
# I used Debian.. :)

# Inside WSL for all commands below

#make sure you are Powershell admin as you enter wsl
#inside wsl prompt don't use the local zpool or zfs
#use
#zpool.exe and zfs.exe
#they will access the mounted zpool / data drive you created in Windows environment, no problem:
#but the zfs.exe send / receive would only work for me with ssh.exe when run inside WSL (I could not get piped zfs.exe send ...| ssh.exe....to work without using WSL.

#create snapshot
zfs.exe snapshot tank/d@test0

#first zfs send [ dest directory is automatically created in first regular zfs send command, at receiving server ]
zfs.exe send tank/d@test0 | ssh.exe root@192.168.X.Y zfs receive proxmoxpool/data@$(date +%m%d%Y-%H%M)

# OBSERVE command line above has 2 exe, and one none .exe, since receiving server is Proxmox but all local commands, inside WSL, are .exe.

#once the first transmission worked successfully, incremental are also possible
zfs.exe snapshot tank/d@test1

zfs.exe send -i tank/d@test0 tank/d@test1 | ssh.exe root@192.168.X.Y zfs receive -v proxmoxpool/data@$(date +%m%d%Y-%H%M)

# ----end inside WSL

# I think it would be good before Windows shutdown
zpool.exe export tank
# if you remember / can script it. Given the beta stage. It needs zpool.exe import after every re-start. (can be automated I read)

Now I just need to create a script inside WSL that can get triggered outside WSL, by windows .BAT / Scheduler, even if WSL is not started by family members, project for later.

P.S.
this is useful,
https://github.com/bahamas10/zfs-prune-snapshots
but be careful, don't forget to specify pool/data, when using the
"zfs-prune-snapshots 1w pool/data"
or similar.
D.S.
 
Last edited:
Since Sanoid/Syncoid don't call for the zfs.exe inside WSL, I have set it up as this for automation:

#enter WSL
wsl
nano test.sh
#!/usr/bin/env sh
zfs.exe send -i tank/data....etc per you needs

#exit WSL
exit

#In Powershell the command is
wsl -e ./test.sh

to automate make script file "wsl.ps1" with one line inside
wsl -e ./test.sh

https://lazyadmin.nl/powershell/how-to-create-a-powershell-scheduled-task/
Win start
Task Scheduler
Create Basic Task
give it a name,
set frequency
select "start a program"
program script: Powershell
add arguments: -NoProfile -ExecutionPolicy Bypass -File "C:\scripts\wsl.ps1"
start in: c:\scripts
Click finish, then right click the Task created, select Properties, select box: run whether user is logged in or not

then with file explorer go to c:\tank\
right click create shortcut to c:\tank\data folder.
move shortcut to user Desktop, and tell user to use it for important files.
 
updated script for recurring automation, and date time format matching Sanoid/Syncoid

#!/usr/bin/env sh
zfs.exe destroy tank/data@v1
sleep 2
zfs.exe rename tank/data@v0 tank/data@v1
sleep 2
zfs.exe snapshot tank/data@v0
sleep 2
zfs.exe send -i tank/data@v1 tank/data@v0 | ssh.exe root@192.168.X.Y zfs receive -v proxmoxpool/win10@$(date +%Y-%m-%d_%H:%M:%S)
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!