Daily db backups in Phoenix/Elixir -- what's the best way?

I have a Phoenix app. What’s the best way to do daily pgsql db backups?

  1. Cron and a simple, separate elixir script which uploads a backup to AWS?

  2. Create an api endpoint in my api which will require “SECRET” header and call it from cron? My webapp then will upload a backup to AWS, that is, there’ll be no separate elixir script.

  3. Genserver?

1 Like

I always feel like the more secure way is to have the backup machine pull it’s backups instead of trusting the machine itself to push it somewhere.

4 Likes

Not sure why you’d need to do this specifically in the application/elixir/phonenix, unless you need to maintain some kind of meta data, or want to provide some kind of in-app restore functionality? Maybe this is my curmudgeonly sysadmin brain, but I’d probably just do this entirely out of the application and deal with it in at the system level. i.e. If I had a full backup solution already, I’d be using that. If I didn’t, I’d probably be scripting something up using pgdump and cron

5 Likes

I agree. This is really a database management issue and not an application issue. As far as the “best” way that depends on needs. I have found the officially provided bash scripts from Postgres to be very helpful.

https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux

4 Likes

I agree. This is really a database management issue and not an application
issue. As far as the “best” way that depends on needs.

And if you’re already using AWS, “best” might mean “least manual
fiddling” in which case just use RDS and get backup automatically :slight_smile:

4 Likes