Restore to NTFS from BTRFS

I am restoring files that were backed up from a BTRFS partition to an NTFS partition stored using a rest-server. I have a large number (thousands) of poorly named files with characters like question marks, pipes, colons and other characters NTFS is not a fan of. It is producing errors like:

ignoring error for {file path}: open {file path}: invalid argument
ignoring error for {file path}: lchown {file Path}: no such file or directory

• The output of restic version.

$ ./restic version
restic 0.17.3 compiled with go1.23.3 on linux/amd64

• The complete commands that you ran (leading up to the problem or to reproduce the problem).
$ ./resticprofile {profile}.restore latest

Which I expect to be producing:
restic -r "rest:http://{server_username}:{server_password}@{host}/" --password-file "{file_path}" restore latest --target "/"

• Any environment variables relevant to those commands (including their values, of course).
None

• The complete output of those commands (except any repeated output when obvious it’s not needed for debugging).

2024/12/17 22:17:28 using configuration file: profiles.yaml
2024/12/17 22:17:28 profile '{profile}': starting 'restore'
repository {identifier} opened (version 2, compression level auto)
[0:00] 100.00%  33 / 33 index files loaded
restoring snapshot {identifier} of [{directory}] at 2024-12-17 19:25:06.890322146 -0500 EST by {user}@{host} to /
ignoring error for {file path}: open {file path}: invalid argument
...

ignoring error for {file path}: lchown {file Path}: no such file or directory
...


[28:48] 100.00%  4356 files/dirs 10.041 GiB, total 31329 files/dirs 10.041 GiB, skipped 471919 files/dirs 393.557 GiB
Summary: Restored 31329 files/dirs (10.041 GiB) in 29:09, skipped 471919 files/dirs 393.557 GiB
Fatal: There were 12069 errors

2024/12/17 22:46:47 restore on profile '{profile}': exit status 1

The skipped 471,919 are from a previous restore and those files are recovered successfully. 12,069 files have characters NTFS isn’t a fan of, like “:”, “|”, etcetera. I do not have the option of changing my file system.

Is it possible to have restic auto replace characters with something like an underscore? Otherwise, does anyone have any other ideas on how to restore these files to a NTFS file system?

You can always restic mount the backup on the NTFS machine and then use some other tool to copy the files over. Maybe there is a tool that will automatically rename files with illegal characters in them?

Interesting use case or problem :slight_smile: Let us know if you have any luck with the mount approach suggested above!

Would it be an option to restore it onto a temporary BTRFS or similar, and moving the files from there (with this detour you will have tons of options for fixing the filenames so that they are something NTFS is happy with)?

Out of interest I just duckduckgoed (duckduckwent?) this problem and it seems like Windows can’t even adress a file like that so it can be renamed. This page suggests using a tool called PowerRename but due to a lack of a Windows installation I can’t test it.

Thank you for the suggestions folks! In the end I went back to Linux, mounted the NTFS partition with ntfs-3g’s windows_names option and restored again–and for good measure I also mounted the restic backup and simply copy/pasted the files.

It was still unhappy about the situation, but windows_names (presumably) automatically converted the filenames by replacing the special characters with underscores. Spot checking several of the most problematic directories revealed the same file counts and sizes so I believe I’m good.

2 Likes

I wonder if restic mount then rclone copy --local-unicode-normalization would have worked? :thinking:

Also using something like Detox on a Linux system first might help? But it’s just going to preemptively replace symbols with underscores.

detox was next on my list! rclone somehow didn’t come to mind though nor did mounting the backup either. :grinning:

1 Like