creativeprojects / resticprofile

Configuration profiles manager and scheduler for restic backup
https://creativeprojects.github.io/resticprofile/
GNU General Public License v3.0
747 stars 33 forks source link

[New feature] Client/Server model and pull backup #69

Open creativeprojects opened 3 years ago

creativeprojects commented 3 years ago

Today, all the backup operations are initiated by the client (push). What if you would want a backup server asking for files from the clients? (pull).

I'm opening this issue as a discussion around the client/server model: a resticprofile server could wait for commands to trigger a backup, via a simple REST API.

Is it a good idea?

jkellerer commented 3 years ago

That's funny, because before stepping over resticprofile, I was thinking that it would be nice to have a server to manage restic configuration and clients that securely connect to the server to apply it on endpoints. Combined with a management web UI (for admins) to control auth, clients and settings, and a self-service UI (for endpoints) to restore data from snapshots. From my perspective this is a good idea, but it has to be done very carefully as it can lead to serious loss of information.

Some thoughts:

Design considerations:

jkellerer commented 3 years ago

While it is a side effect when backup schedules are controlled by a central unit, I'd like to add that push based scheduling allows to use backup queues per repository that control backup concurrency and limit load. E.g. a profile with a schedule of "Every day at 12:00" could run on a larger amount of endpoints when only some endpoints may run the backup concurrently.

This can even make sense with a hand-full of endpoints when the repo is something like a consumer NAS. Current solution is to have different schedules for different endpoints.

creativeprojects commented 3 years ago

It looks like we do have similar ideas 😄

Client & server communication must be implemented with very high security standards. E.g. TLS-1.3+ and exchange of public keys like in SSH or Wireguard.

This one is tricky though:

jkellerer commented 3 years ago

I'd not strip down security just because someone could have the impression that it can be used securely without VPN. Personally I do not trust my own network since any desktop (or server) could get infected and attack others to some extent. If it can be done in a secure way and still work quite simple (e.g. public key exchange using a key that is not too long when string encoded), I'd use that but still mention that it is not a good idea to use it without VPN or similar.

creativeprojects commented 3 years ago

Winter is coming so I'll have a bit more time at the week-ends: I'll start preparing a design document 😄

jkellerer commented 3 years ago

Same here (regarding time :)). Wanted to create a quick prototype on HTTP(S)+Websockets+SSH (SSH via Websockets for identification, commands & logs, HTTP/S for everything else). Was thinking about the communication part a bit and while client-certs can be a solution to identify agents uniquely, using HTTPS only means that middle boxes or proxies may create issues (technical and data protection). Embedding SSH with websockets allows to use something proven that is secure even when outer transfer is only HTTP. Nevertheless my aim is just to test whether this works well without heavy externals dependencies. It should not mean that this has to be the way to go.

creativeprojects commented 3 years ago

Funny enough I was doing a quick PoC the other day: transparent AES encryption over HTTP. I'm not sure how usable it actually is, but it's very simple: https://github.com/creativeprojects/encryption

creativeprojects commented 3 years ago

Randomly, I just found this discussion 🤔 https://github.com/restic/restic/issues/299

jkellerer commented 3 years ago

Thanks a lot for reference. My (somewhat biased) takeaways are: There is a demand for a pull based system and it may be sufficient to use a remote shell for this. While both client and backup-server must be protected its important that a client has minimal access to the backup so that malicious software cannot easily do harm. For the same reasons the repository should not require to be reachable in the same (e.g. public) network as where the client sits.

I'd add that it is also very crucial that the client has to be protected to avoid take over or dataloss so a too permissive remote shell or even a homegrown remote-fs doesn't sound like a good plan.

While it seems there is something going on @ restic/restic with regards to pulling from remote sources, I think for resticprofile it still is good to consider supporting pull based operation. This could be done with remote shell support instead of implementing a full client & server model which would be the much higher hanging fruit and harder to maintain.

jkellerer commented 3 years ago

As a quick wrap-up this is what I think would be required when we choose to support remote shells:

General

Security

Usability

Under the assumption that the best match for a remote shell is SSH to begin with, the only disadvantages I see is supporting Windows and Desktops as in both cases SSH is uncommon.

creativeprojects commented 3 years ago

I think I like this version better than the original idea:

With this, no need to create a separate service, install it on a client and wait for requests. All we need is allowing SSH to the machine. There's openSSH included in Windows 10 now (maybe starting with pro I don't know, but I had it on my Windows laptop at my previous job)

We could also implement ephemeral keys: the server creates a new repository key before sending it to the client and destroys it after the backup is finished. Although if the attacker already has access to the client, it could potentially intercept the backup request and steal the key. Still, that's another level of protection to go through.

creativeprojects commented 3 years ago

Quick ideas: https://github.com/creativeprojects/resticprofile/wiki/Design

Are you able to update the wiki? (I never used that feature before)

jkellerer commented 3 years ago

I've not used it either. Looks like I can clone it but not push. Also have no buttons for editing.