π

Restic Backup on Windows 10 with Babun/Cygwin

Show Sidebar

Update 2019-03-13: comments Florian.

I heard great things about restic for solving the backup requirement.

Since it does also support Windows, I gave it a try on my business Windows 10 and my babun environment, which is a user-land Cygwin with better presets.

Here are my findings.

Installation

I downloaded restic from its GitHub release page (v0.9.0) and according to the installation documentation I moved it to C:\Windows\System32\ which I found a bit odd recommendation, modifying the sub-hierarchy of Windows system files. So far, I moved files to a directory which is part of the PATH environment variable. This time, I followed the instructions strictly.

The bash/zsh autocompletion setup did not work on my babun-zsh and I did not invest time to debug this issue. I guess it relates to not knowing where to store the resulting file.

Setting up a New Repository

As far as I understood the documentation, restic follows some ideas of Git. It is chunk-based, identifies files with hashes (renaming and moving files do not result in additional backup effort), de-duplicates files, and uses so called repositories to store backups. Further more, it seems to be the case that restic is able to store backups from multiple locations in one single repository. Very cool: repository encryption is built-in right from the start.

And this is where I had to get creative: there is a known issue with the password prompt on Windows. I could have installed a thing called winpty (I don't know so far). However, I chose to try a different approach: storing a long passphrase in a text file and use the --password-file command line option.

And it worked: without the --password-file option, restic was stuck without any error or warning message. With the option, restic was able to initialize the repository:

 export PWFILE=path/to/keyfile
 restic init --repo "T:\restic-backup" --password-file $PWFILE	  

As you might notice, restic on Cygwin needs Windows-style paths. Cygwin usually uses paths like /cygdrive/t/restic-backup/ but restic does not accept them or handles them in a wrong way. You have to use Windows-style paths, not being able to use shell completion for paths.

Backup

My first backup was easily done:

 restic -r "T:\restic-backup" --verbose backup \
   "C:\Users\karl.voit\data" --password-file $PWFILE	  

Yes, it's true: restic is fast.

The same command runs an update on the backup and a new snapshot is created.

Curating Backups

List all snapshots of a repository is done like:

 restic -r "T:\restic-backup" snapshots --password-file $PWFILE	  

Something that worries me a bit is the necessity of the recommendation to periodically check the integrity of a backup. This can be done with:

 restic -r "T:\restic-backup" check --password-file $PWFILE	  

Restore

Restoring a single file is easy:

 restic -r "T:\restic-backup" restore latest \
   --target C:\Users\karl.voit\restore-test \
   --include "relative\path\file.txt" \
   --password-file $PWFILE	  

I found out that using absolute paths for --include did not work: restic returned with no error or visible result. So please do use relative paths for include or exclude statements.

Summary

It was nice to see that restic is a clever backup solution with built-in encryption that even works on Cygwin-like environments.

There are some drawbacks such as the missing path completion on Cygwin/zsh and some trial and error around using absolute or relative path names for this and that.

I am not sure why the manual mentions the necessity of periodically checking the integrity of repositories. This might indicate issues where restic corrupts repositories or this might just indicate the possibility of errors introduced by external things.

I am not using restic for the time being. This is not related to restic itself but other circumstances in our Windows environment.

However, it is good to know that there is something out there which might replace my hand-crafted rsync-scripts some day.

Comments

Florian wrote me that he did not face any issue with the password prompt on Windows 10 with Restic 0.9.4 and PowerShell ISE.

Related to "periodically checking the integrity of repositories", Florian thinks that this refers to other people modifying the repository like deleting a file or losing data by bit-flips on the storage media.

Comment via email (persistent) or via Disqus (ephemeral) comments below: