I have a Rails app server that uses Postgres for the dbDB backend. I'm spinning up a new server and I want to get a clean and up to date copy of the database. I've tried it once so far while the server was in production by doing the following:
- As user postgres: pg_dump databasename > databasename.sql
pg_dump databasename > databasename.sql
- scp
scp
the databasename.sqldatabasename.sql
file over to the new server - As user postgres pn the new server enter psql and create the database and alter ownership
- As user postgres run psql databasename < databasename.sql
psql databasename < databasename.sql
All of this will occur after I shutdown Nginx/Passenger so all sessions will be terminated and no more data can come in/go out of the system. The only thing running will be postgres which no one can connect to directly.
Does this sound like a reasonable plan to migrate the database from one server to another? The database is 12MB in size, probably 30 tables, and has maybe 50K records so it's pretty small.
Any advice on how to do this cleanly and to make sure my data is "sane" would be great. I've done this via mySql before but only done it via m