How-to

Move a database from one VPS to another

To move a database the following steps have to be done.

  1. Prepare (Install Go, VS Code and pgAdmin)
  2. Run the script using Go
  3. Use pgAdmin to check that the database is transferred correctly.

My script consists of 8 steps. Step 8 runs only if the user is changed.

  1. Set the parameters for the old an new server.
  2. Create an empty dump.custom file.
  3. Create correspondent user on the new server.
  4. Create a database on the new server.
  5. Dump the old database into dump.custom.
  6. Send (restore) the database to the new server.
  7. Change to original user of the new database.
  8. IF the user is different, change owner for the entire database.