r/zfs•
EVnegative

Restore single file from encrypted remote

I'm looking for a remote backup solution. The goal is to:

  1. have the entire backup encrypted, including metadata such as how many files there are, file names, modification timestamps, ...
  2. back up incrementally, ideally with daily/weekly/monthly snapshots each kept for some time (e.g. dailies kept for 1 week, weeklies kept for 1 month, ...)
  3. be able to restore a single file from a given point in time without downloading entire snapshots or increments and without sending any decryption keys to the remote. E.g. "give me /home/myuser/list.txt from the last snapshot before 2021-03-26"

As far as I can tell, many tools, including ZFS with zfs send, are able to do the first two. I can't figure out how to do the third, though.

It seems it should be possible; in the worst case ZFS could treat remote files as (very slow) block storage and read as needed. Transmitted data and remotely stored data would always be encrypted, only locally decrypted. Perhaps with a remote mounted over sshfs or NFS, with ZFS creating block files on the mounted directory?

Has anyone succeeded in doing this? Are there tools to help set this up?

Posted Mar 28, 2021, 10:58 PM UTC

111
someone8192•

I just use borg for backup. Remote and local. Encrypted, deduped and mountable through ssh

3
EVnegativeOP•

Thanks for this! I just read their FAQ and docs. It seems like it does what I want.

Although it unfortunately doesn't use ZFS streams to get changes since the last snapshot.

I do wonder how their extract command fetches individual files from an untrusted remote.

1
someone8192•

The untrusted remote is encrypted and the key never leaves your local system

2
thenickdude•

If it works anything like Duplicacy, there is a file index stored on the remote (encrypted, of course). It fetches that first and then uses it to know which blocks it needs to fetch to reconstruct each file.

1
ElvishJerricco•

Well for #1, ZFS encryption already breaks your rules. An encrypted dataset leaks how many files there are and how big they are. But #3 seems like it would make any solution impossible. How could the remote identify a file by name and where all its contents are if it can't know where the files are or their names?

2
EVnegativeOP•

I read that ZFS encryption would only leak the total size of the volume, since it's not individual files being transferred, and the remote can't read the encrypted blob as it's being stored by ZFS. Incremental backups would then leak how much is changed every day/week/..., but not file count or file size. Is that not correct?

2
ElvishJerricco•

Read the man page:

ZFS will not encrypt metadata related to the pool structure, including dataset and snapshot names, dataset hierarchy, properties, file size, file holes, and deduplication tables (though the deduplicated data itself is encrypted).

2
EVnegativeOP•

Thanks! I had based myself on this blog post, but that's not correct, then.

1
zfsbest•

--I don't deal heavily with zfs encryption, but as long as the remote is running ZFS you should be able to ssh over, mount a zfs snapshot on the remote and just use cp or scp (or even midnight commander) to copy the file to local?

​

--If you're just storing a binary encrypted blob on the remote end without running ZFS, your life is not going to be simple when you try to restore...

1
EVnegativeOP•

If the remote is running ZFS, I can get at the files, but then the remote sysadmin could see my file as it's prepared to transfer over, right? I'd want the decrypting to happen on local.

I know it's possible, I just don't know which tool(s) will get me there. I believe the blobs thing would work, but as you say, not simple and probably also very slow...

1
solen-skiner•

you could do something like zfs send | ssh tee file, tho, couldnt you?

is there a tool to zfs send from a file? can you do something like zfssenddumpcat file | zfs recieve somehow?

1