ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.7k stars 385 forks source link

Add backup routine for search index / indices #166

Closed nilslice closed 7 years ago

nilslice commented 7 years ago

Much like the backups for uploads and databases, we need to add a backup handler for the search directory which is created and updated by the full-text search feature.

To keep in-line with the current backups, the request should be: /admin/backup?source=search

The handler is located in system/admin/handlers.go and should be implemented in the search package, with the same function signature as the other backup methods (will eventually create an interface to backup).

A good starting point would be to mimic the upload backup implementation, but if anyone is interested, the implementation could be abstracted from it since a nested directory tarball is fairly common. See the upload backup implementation in system/admin/upload/backup.go for details.

If anyone would like to take this on, it would be super helpful, and it slipped my mind when implementing the search feature initially - so I apologize!

I'll pick this up if no one can within a week or so (I'll update this as soon as I start to avoid any duplication of effort) -- please add a comment if you are able to help or just have thoughts about the feature.

tom-f commented 7 years ago

Hi, here's a minimum effort approach https://github.com/ponzu-cms/ponzu/pull/168

I wasn't sure about how far to take the abstraction so left it small for now. But maybe an Archive closure over func Backup(ctx context.Context, res http.ResponseWriter) error could remove more duplication

nilslice commented 7 years ago

@tom-f fantastic! still running a couple manual tests, but I should be able to merge this later today. Thank you for your help (and for so quickly responding to this issue)

Let's keep the abstraction simple for now -- this is a great starting point -- and see what else people need to backup (maybe stuff in addons, etc), then generalize further or add to the backup package so it's easy for anyone to implement a http backup of their things.