Getting started - stumped at SFTP

I’ve been able to stumble through ‘Preparing new [Local] Repository’ but, when I get to SFTP step, I get the following error response which I don’t know how to get around:
PS C:\Users\Administrator> restic -r Administrator@WIN-TSXXXXXX57E:/srv/restic-repo init
enter password for new repository:
enter password again:
Fatal: create repository at Administrator@WIN-TXXXXXXXX7E:/srv/restic-repo failed: invalid backend
If the repo is in a local directory, you need to add a local: prefix
The Repository directory is C:\svr\restic-repo but I can’t figure out where to put that location in this SFTP command.
Apologies in advance if this is a stupid question, if it is I openly confess to my amateur status.

  1. I don’t see a schema, don’t you need to prefix with sftp:?
  2. How exactly the SFTP path translates to a windows path, depends on the SSH server in use. The easiest would probably to connect via SSH and then explore the disk to figure out.

Thanks Norbert for your prompt reply. Unfortunately, your response went way above my pay grade, but I’ll do my best to clarify:

  1. I’m not sure what you mean by “schema” The command shown is as per the Restic documentation instructions.
  2. I’m not knowledgeable in SSH and would need guidance on what to do and what to look for.
    In a nutshell, I’m simply trying to set up a Restic backup/restore regime to replace the faultering Windows Server MMC/VSS procedure, which has encountered an error to do with System Writer not present, apparently a common Windows Server demon.
    I unsuccessfully tried all the supposed remedies to correct the System Writer problem, so Restic is a potential replacement solution if I can get past the initial setup.
    Regards

In this context the schema is sftp: which your repository target is missing. This section of the documentation gives examples for using SFTP. You need to use sftp:Administrator@WIN-TXXXXXXXX7E:/srv/restic-repo

Thanks for your reply.
As per my OP, the SFTP command I’m entering is as per the documentation:
PS C:\Users\Administrator> restic -r sftp:Administrator@WIN-XXXXXXXXE:/srv/restic-repo init
But the response from restic is:
PS C:\Users\Administrator> restic -r sftp:Administrator@WIN-TS0D9CG057E:/srv/restic-repo init
enter password for new repository:
enter password again:
subprocess ssh: ssh: connect to host win-ts0d9cg057e port 22: Connection refused
Fatal: create repository at sftp:Administrator@WIN-XXXXXXXE:/srv/restic-repo failed: unable to start the sftp session, error: EOF
Could this refused connection be a Firewall issue?
Or am I trying to connect to something that doesn’t exist? AFAIK, the previous step to create a Local Repository was processed successfully.
There is a Windows directory called C:\srv\restic-repo which contains these folders: data (256 sub folders, all empty); index (empty); keys (1 file); locks (empty); snapshots (empty).

Or am I trying to connect to something that doesn’t exist? AFAIK, the previous step to create a Local Repository was processed successfully.

I think what might have happened here is you completed the “Local” repository setup steps, but then have started on the “SFTP” steps as they’re immediately below the “Local” steps in the “Preparing a new repository” section of the guide.
You only need to complete one set of steps, depending on what kind of repository you’re aiming to setup.

There is a Windows directory called C:\srv\restic-repo which contains these folders: data (256 sub folders, all empty); index (empty); keys (1 file); locks (empty); snapshots (empty).

From the looks of things, you’ve already run “init” successfully and created a local repository, so you don’t need to follow any of the other sections under “preparing a new repository”.

If you want to check you can access the local repository before going any further, you could run something like the below, although it won’t list any snapshots, because none have been taken yet:

restic -r C:\srv\restic-repo snapshots

Assuming the above is correct, you probably now want to move onto “Backing up” - Backing up — restic 0.16.3 documentation. I’d suggest backing up a small directory first to get to grips with how restic works, before trying to back up your full dataset :slight_smile:

1 Like

"run something like the below, although it won’t list any snapshots, because none have been taken yet:
restic -r C:\srv\restic-repo snapshots
created new cache in C:\Users\Administrator\AppData\Local\restic

Assuming the above is correct, you probably now want to move onto “Backing up"

Thanks for that, seems this is promising progress.

I’m wondering given the above cache created in C:\Users\Administrator\ . . [etc], does this mean the target destination for backups will be to this C:\Users . . . \AppData folder?
I’ll want to target an external USB HDD, so I’d like to clarifiy that please.
Thanks again for your guidance.

The target in your example would still be C:\srv\restic-repo, and you could freely change this to something on an external HDD: it’s independent of the cache location.

Maybe a dumb question, but what purpose does the ‘cache location’ serve?

Geoff Whiteley

Maybe a dumb question, but what purpose does the ‘cache location’ serve?

It stores some stuff locally (metadata) to speed up certain restic operations. You could move the location if you wanted, using the --cache-dir switch, but unless you’ve a specific reason to I’d recommend just leaving it where it is.

More info:
https://restic.readthedocs.io/en/stable/cache.html
https://restic.readthedocs.io/en/stable/manual_rest.html#caching

Great info, thanks again. My instinct tells me to leave it where it is, but it’s handy to know about that switch option.

Geoff Whiteley

Please consider moving the repository to a different drive soon!

Backups should not be on the same physical drive as the data they back up.

If your drive faults for some way, the only way to recover it’s data lives on the very same drive.

A first step is using an USB drive, using an off-site storage like B2 or S3 is the second.

Hi Norbert, please clarify whether by the term ‘repository’ you’re referring to the “cache” created by restic -r C:\srv\restic-repo snapshots

@GeoffW I think you would benefit from reading the documentation for restic :slight_smile:

For example, in Preparing a new repository — restic 0.13.1 documentation which is one of the first chapters, it clearly explains what a repository is.

Also, by executing restic.exe help you will get a list of commands and a short summary of what they do. You’ll then see that the snapshots command “lists all snapshots”, which is not a “create a repository” action.

You can also execute restic.exe help <one of the commands here> (e.g. restic.exe help backup) to get help about a specific command, including a list and summaries of the options you can supply to that command.

I recommend that you at least skim through the topics in the menu on that documentation site, and read up on the commands you find to be of particular interest/use to you.

Thanks for your helpful guidance, and apologies for my cretinous level of knowledge.
I’ve been reading the documentation and have just now tried a sample backup (after guessing that ~work is something that Windows doesn’t understand). So I ran a dummy backup of one small directory and was able to follow the intructions to delete that backup.
Sadly, both for me and probably also for the majority of people on this Forum whom may try to assist, I have very limited experience in programming and running system commands (in particular Linux syntax).
As per the above Q&A in my ‘Getting started’ thread, I have a very limited understanding of the restic architecture and, given my early exposure over the last few days, can see this is a very powerful tool that I hope to be able to effectively harness.
But that will probably take more than the documentation seems to provide as, although very complete in detail, it doesn’t seem to offer a step by step flow that a novice can folllow.
For example, the earlier discussion about ‘cache Vs repository’ had me stumped, until I ran the small test backup. But now I can’t find instructions to explain how to have my restic instance reside on a storage device other than my C:\ system drive, without fear of breaking anything inside the restic ecosystem.
I’m sure there’ll be other stumbling blocks as I move forward with this, and I’m hopeful that the generosity and patience of Forum members will help me prevail to get restic running in production.
Cheers

Yeah, Windows isn’t something that most people here use I think, so it’s not the main target for the documentation either.

That said, most of it all is more or less directly translatable into Windows, one just has to run e.g. restic.exe instead of restic, but the restic commands and so on are the same. Of course the paths for your system will be different (e.g. C:\foo instead of /foo and so on), but that’s expected to be understood. So in summary, most of it is the same, it’s just the stuff outside of restic that differs.

Where do you want to store your backups (the repository), and what files/folders on your system do you want to back up?

Agreed, not too sure about your ‘restic.exe’ point, as in Windows Powershell I’m able to run commands just with ‘restic’. But I digress.
I have 2 USD HDD hanging off my Server, one of which I’ve been using for Windows MMC/VSS backups (Bare metal, System Recovery and selected data files). That all came to a screaming halt 3 weeks ago when I’d tried installing and running Jellyfin (Media Server) as an experimental potential replacement for Plex. The install went belly up so I uninstalled JellyFin and experienced several dreaded BSOD incidents. As Jellyfin was the only structural change I’d made I blamed some gremlin in the install/uninstall process so decided to revert the system to prior to the Jellyfin incident.
BOOM!
The restore failed because “System Writer not present” and I subsequently found backups no longer worked giving the same error. So I could not only backup (or restore) and I now had serious doubts about Windows Backup, went looking for Open Source solutions, here I am.
The USB HDDs on my system are drives D: & F: (D: is currently holding a System Restore backup) so I’m thinking F: is the target for restic, initially data files but I’d also like to setup a backup process for windows system recovery stuff.
Any tips you can offer would be very welcome.

You are right, one must not use .exe in the filename, it’s just old-school me that’s used to it. As long as you know what you’re doing! :+1:

So you want your restic repository to reside on the F: drive, e.g. at F:\Backup. Then the commands to initialize and then back up your files would be e.g.:

restic -r F:\Backup init
restic -r F:\Backup backup "C:\Users\My Username\Documents"

I don’t use restic on Windows so perhaps something is off with the commands, but it’s a starting point. Feel free to try them.

NOTE: In the example I used the --repository-version 2 option with the init command. This is so that your repository supports the new compression feature which will be in restic 0.14.0 (released very soon). It does however require that you use that version of restic, otherwise the option will not be recognized by the init command. EDIT: Repository version 2 is the default in restic 0.14.0.

Until that version (0.14.0) has been released you can grab a copy of it over at the beta site here: https://beta.restic.net/latest/restic_v0.13.0-388-gad6eabbf_windows_amd64.exe (don’t be fooled by the version in the filename, it really is the upcoming 0.14.0 version in this file).

If you don’t want to use that specific program file for now, you can just wait a few days and you’ll be able to download restic 0.14.0 from the usual release page.

Thanks for those helpful tips, much appreciated. I think I’ll wait for the 0.14.0 release. Beforehand, to eliminate any possible misunderstanding on my part, I just ran:
PS C:\Users\Administrator> restic -r /srv/restic-repo snapshots
enter password for repository:
repository e2dafb3c opened successfully, password is correct
PS C:\Users\Administrator> restic -r /srv/restic-repo check
using temporary cache in C:\Users\ADMINI~1\AppData\Local\Temp\2\restic-check-cache-3758304380
enter password for repository:
repository e2dafb3c opened successfully, password is correct
created new cache in C:\Users\ADMINI~1\AppData\Local\Temp\2\restic-check-cache-3758304380
create exclusive lock for repository
load indexes
check all packs
check snapshots, trees and blobs
[0:00] 0 snapshots…
no errors were found
I’m presuming this is the result from initial (experimental) setup and I need to redo this to send my backups to F: (instead of my C: system drive).
I thought I’d already done the ‘forget’ routine but this seems to be the current repository. Do I need to remove this repository and re-establish my future production repository on F: before proceeding with the new release backup?

Yes, this repository is one, and the one you will later (when 0.14.0 is released soon) create on e.g. F:\Backup is another repository. They have nothing to do with each other, and if you aren’t using the current one at /srv/restic-repo then you can just delete it. Remember, it’s just a set of files and folders - have a look at it in your file explorer and you’ll see that it’s not something scary :slight_smile:

Have you read up on the init, backup, snapshots, forget, prune and check commands so that you know what they do? If now, make sure you understand these basics so you use the right command. Then you should be ready to make use of them!

You have both the documentation website and the inline help at restic help and restic help <command>.