Flink / dokku-psql-single-container

Plugin for dokku that provides a Postgresql server in a single container
MIT License
51 stars 9 forks source link

Continuous archiving? #13

Open isundaylee opened 9 years ago

isundaylee commented 9 years ago

I was looking for a way to incrementally backup PostgreSQL, and came to this feature here http://www.postgresql.org/docs/9.1/static/continuous-archiving.html Maybe it is useful to add commands to this plugin to enable that?

Currently we have psql:dump and psql:restore for backup and restoring. They are great and simple. However, they both operate on a single database (which, in itself, is often desirable), and all operate on a complete backup for the database. In addition to this, I think it'd be useful to have a incremental backup solution for the all databases at once (just for disaster recovery case).

It could be something that works like:

And for disaster recovery, the user can rsync the archive files back to psql:archive_path, and then run psql:archive_restore.

I can write a PR to implement this if it sounds like something useful :)

Flink commented 9 years ago

Hey Jiahao!

Sorry for answering a bit late, I'm on vacation ;) Your idea seems great albeit it seems quite complex too (quickly read your link) so yes if you want to write a PR, you're welcome :smile:

Maybe we could use psql:cab:enable, etc. as commands? (cab for Continuous Archive Backup) Just an idea, what do you think?

Anyway, thanks for your idea and help :+1:

Flink commented 9 years ago

Also you should target the develop branch when developping your feature instead of master, thanks :)

isundaylee commented 9 years ago

I like the suggestion about psql:cab:subcommand! And yeah, I'll target the develop branch.

So I tested the idea out a bit, and I think it's very feasible. There's one thing we need to think about, though: how do we get the files out of the container?

I tried putting all the archive files in a archive directory under the data folder. However, the mounted volume (at $PSQL_ROOT/.psql_sc) doesn't seem to grant access to anybody (owner uid 999). Maybe that should only be accessed by Docker itself?

Any idea on that? Thanks! :)

Flink commented 9 years ago

Well, I don't know if access is a problem. I think backup should be an administrative task and so you should have a sudo/root account access to do whatever you want. Another possibility is to use docker cp I think.