Do not use SMB over Internet - it is not designed for it and performance will be terrible.
There are much better options e.g. sftp or if you don’t mind a little bit more config install minio and use S3.
And plan carefully your VPN setup… otherwise if your VPS is compromised somebody can get full access to your NAS. So only allow ports you really need etc. As a minimum I would only VPN between vm/jail/docker running on NAS and VPS.
And overall to avoid serious security problems I would backup VPS to some cloud storage and then on my NAS use restic replication to copy it from this cloud to local NAS storage.
I would consider ad hoc vpn solutions for that like zerotier or tailscale. Especially if you don’t have a lot experience with building vpns by hand. It’s up and running in minutes while still gives you quite high security.
You can then use restic through that secure tunnel.
This works very well for me. On the backup server (behind NAT) I use rest-server and autossh to have an always-on tunnel to the host-to-be-backed via crontab:
Thanks I think I understand this:
Please correct me if I’m wrong rest-server running at port 8000, mapped to localhost:1337 on VPS. restic runs on VPS (already has tunnel established through autossh) and uses user from local machine.
Also I see sftp should be part of ssh, does rest-server bring any other benefit?
I’ll look at autossh and how to read ssh-key through script.
Yes, rest-server uses port 8000 on the receiving server which is tunneled to 1337 on the client. restic runs on the client but it’s started remotely, mainly because I have a script that backs up multiple machines one after the other and because I don’t have to have the restic repo password on the client that way (check out --password-command).
“user:pass” is the rest-server authentication (you have a .htpasswd file there). For me, the main advantages in using rest-server are that it’s quite fast, I can have multiple restic repos behind it and it has an append-only mode that keeps a compromised client from easily being able to delete and/or encrypt your backups.
This works and I’ve created backups.
I think required building blocks are in place.
I was trying to automate this process and I’m not sure if I’m doing it correctly.
Please let me know if following is done correctly:
On backup machine:
Create cron to run
Hm yes this works but it’s not very secure as you basically have an open line from the vps to your server now. I don’t recommend using it this way in production.
In my post above I proposed using rest-server which does provide an additional authentication and, if run in append-only-mode gives an attacker who compromised the vps not a lot of attack surface to the backup server.
The ssh tunnel basically just encrypts the http transfer and works without punching a hole into your firewall on the backup server side because it’s opened from within the firewall.
“Rest Server is a high performance HTTP server that implements restic’s REST backend API. It provides secure and efficient way to backup data remotely, using restic backup client via the rest: URL.”
@reboot sleep 20 executes the following command at each reboot and waits 20 seconds before doing so. Just to give your server enough time to start up.