szabodanika / microbin

A secure, configurable file-sharing and URL shortening web app written in Rust.
https://microbin.eu
BSD 3-Clause "New" or "Revised" License
2.66k stars 167 forks source link

Adding a way to backup and restore the pastas #120

Open AuthorShin opened 1 year ago

AuthorShin commented 1 year ago

Hello I would highly appreciate a way to backup and restore the entire database and pastas.

Funding

Fund with Polar

jchia commented 1 year ago

Isn't that accomplished just by copying the database.json file?

AuthorShin commented 1 year ago

@jchia Is it the recommended way? I mean yeah for sure I can do that but what if they change the data structure and the next version won't be able to read the previous version database and just erase it like what happened in here https://github.com/szabodanika/microbin/issues/119.

jchia commented 1 year ago

@AuthorShin IDK if there is a recommended way. I run microbin in docker so for backing up I just backup the entire docker volume to a backup location beyond the reach of microbin using operations on the host machine. Why wouldn't backing up the entire data directory work even if not running microbin in docker?

microbin has no idea where you want to backup. E.g. if you want microbin to backup to S3, then microbin would need to know how to interface with S3. This way microbin would need code for all kind of backup backend, so I don't think backing up is the job of microbin. It just needs to clearly specify where all the data lives and backing up is simply accomplished by copying the files while microbin is not running.

I believe all the data just lives in ./pasta_data so manually backing up that directory while microbin is not running should be enough and if not then there is a bug.

AuthorShin commented 1 year ago

It's dead simple to add a backup and restore button to the app that if you press backup it will generate a .json file for you and when you need to restore it just press restore and it will ask for the .json file and you just locate the file and it will restore it for you, that's all no S3 or whatever.

jchia commented 1 year ago

I'm just saying that there are different forms of backup that people may want to do:

If I understand you correctly, what you are asking for is a button just to copy a file, privileging the last kind of backup over the other kinds.

What I fail to understand is how a "copy file" button will be easier to use than copying the file from the command-line. After you press the button, you still need to know where to find the copy; this is not easier than finding the original file directly and doing whatever copying is needed. Additionally, who has the right to do this? Regular users should not be able to do this from a regular microbin webpage. That then brings up questions about authorization, a can of worms that microbin has not had to deal with so far.

If your concern is format compatibility between microbin versions, then it's a different matter.

AuthorShin commented 1 year ago

If your concern is format compatibility between microbin versions, then it's a different matter.

It's all I'm talking about and maybe the solution for it is sort of a universal import/export by microbin itself to eliminate any possible incompatibility in any environment.

jchia commented 1 year ago

OK, then this issue is predicated on the existence of format incompatibility between microbin versions. IDK yet whether incompatibility issues exist. Maybe someone more familiar with the format can comment.

In any case, I think this issue would interact with #4.