NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.55k stars 2.62k forks source link

Backups/Restore functionality #2109

Open p10tyr opened 2 years ago

p10tyr commented 2 years ago

Is your feature request related to a problem? Please describe. I have just started using nginxmanager quite a lot now with some production services too. I did the easy setup with no external databases so I am wondering how to export/import?

Describe the solution you'd like Export / Backup Import / Restore

Describe alternatives you've considered Don't know.. go into the docker container and hack into the sqllite db??

Additional context Good for distater recovery too if we could just export data into a well known format and have it backup up away from the backup

sanderlv commented 1 year ago

I would LOVE to see this natively from within the user interface ---> hence that's the reason at all I like this product

danielschenk commented 1 year ago

I'm wondering: is atomicity always guaranteed on the sqlite file? In other words: can we be sure that the database on disk is never in an inconsistent state due to ongoing transactions?

If above can't be guaranteed, we need to always stop proxy-manager for a while to be able to pull a safe copy, which can be undesired. In that case, a function to have proxy-manager export a copy (on some kind of trigger which can be automated) would be very helpful. Home Assistant for example has a builtin service for this which can be hooked up to any automation.

p10tyr commented 1 year ago

If atomicity was a problem then SQLite probably wouldn't have been used? I don't think it has to be that over the top. The database only stores config and nothing about transactions so there is almost nothing happening in the databases. As an admin if you are exporting you wont be changing config at the same time you export either.

I was thinking a simple export to CSV function. I have not looked at the code and how it connects to the DB of choice but there should be a simple way to export map config and then reimport it on the other side.

I am not sure about the lets encrypt stuff. There are a lot of considerations here. I would just request a new certificate on the new host. problem solved. If you talking about HA.. or load balancing.. well thats a bigger problem that can be solved in other ways.

Looks like my request is pretty reasonable.. Sorry I haven't been back here for a while.. I mean.. I wouldn't mind looking at the code I guess.. why not!?

danielschenk commented 1 year ago

I'm also not familiar with the codebase at all. I just found your issue because I'm missing this kind of function myself too.

As can be read here atomicity is taken care of, but SQlite uses file locks from the OS for that. If we just read the SQLite file on our own (while proxy manager is also running) we can't be sure that blocks of the file are actually being written because we bypass SQLite's locking protocol. I've noticed that even without changing settings on my instance, the database file gets frequent updates, so I think it's too big of a risk to just read it while proxy manager is running.

Hence I think your feature request is very useful. Why a CSV and not just a copy of the SQLite file?

Regarding the certificates, I think just re-requesting them and not including them in a backup would indeed be the easiest way to solve this.

TicTac9k1 commented 1 year ago

Usually you can do this with copying the data and letsencrypt directory of the compose folder, aka the whole npm docker compose folder.

I would, but copying or tarring gives me permissions errors I don't know for sure are relevant for a successful export, even as root.

https://i.imgur.com/tKfJ3BV.png

Using the jc21/nginx-proxy-manager:latest docker image through docker-compose.yml

smaccona commented 10 months ago

@danielschenk you are absolutely correct that copying the SQLite database file while the database is online is not safe from corruption. SQLite does have several built-in ways to backup a running database:

github-actions[bot] commented 2 months ago

Issue is now considered stale. If you want to keep it open, please comment :+1:

sanderlv commented 2 months ago

Dream on...