Tutorial: Backup from Windows with putty / plink to a sftp server

Hi! I wanted to use restic to backup from a windows computer to a linux sftp server.
I found some hints in serveral threads, i just wanted to share my commands with you.
I did not use the Windows 10 implementation of OpenSSH because some older windows server systems do not have it.

Step 1: install putty via the installer https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
It will install plink.exe which we will need.

Step 2: Create a public/private keypair and install the public key of the server. Do NOT set a password for the private key
You can find hints how to do it here:
https://www.ssh.com/ssh/putty/windows/puttygen
(or google some more links - I am not allow to post more than two links here)
Check with putty that you can login to the server without the need for a password

Step 3:
Download restic for windows, I renamed the exe to restic.exe

Step4: Connect to the SFTP Server by using plink.exe
These are the commands that worked for me:

Login with private key to init a repo (replace init at the end with your restic command)
Here: username = demo

C:\Users\Peter2\Desktop\restic\restic.exe -o sftp.command="'C:\Program Files (x86)\PuTTY\plink.exe' -s -l demo -P 22 -i 'C:\Users\Peter2\Desktop\restic\private.ppk' 192.168.1.190 sftp" -r sftp:demo@192.168.1.190:/home/demo/restic init

Please be careful with the use of double quotes " and single ’ quotes. the sftp.command is surrounded by double quotes " and the path to plink and the path to the ppk-file are surrounded by single quotes ’ !

Here is version for use with a password:

C:\Users\Peter2\Desktop\restic\restic.exe -o sftp.command="'C:\Program Files (x86)\PuTTY\plink.exe' -s -l demo -P 22 -pw 12345 192.168.1.190 sftp" -r sftp:demo@192.168.1.190:/home/demo/restic init

(Use stats instead of init at the end for testing).

Then use your normal restic commands.