Move a database from one VPS to another
To move a database the following steps have to be done.
- Prepare (Install Go, VS Code and pgAdmin)
- Run the script using Go
- 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.
- Set the parameters for the old an new server.
- Create an empty dump.custom file.
- Create correspondent user on the new server.
- Create a database on the new server.
- Dump the old database into dump.custom.
- Send (restore) the database to the new server.
- Change to original user of the new database.
- IF the user is different, change owner for the entire database.