Dumping a pgSQL database on shared hosting through the command line can be a daunting task for users. However, this article offers a practical solution by providing a step-by-step guide to accomplish this process successfully.
By following the outlined steps, users will learn how to access and manipulate their pgSQL databases efficiently using the command line. This solution empowers users to take control of their database backups and perform necessary maintenance tasks, even within the constraints of shared hosting environments.
This article explains how to dump a pgSQL database on shared hosting via the command line.
Dump pgSQL Database on Shared Hosting
- Acquire credentials to the PostgreSQL database user assigned to the database
NOTE: You can also create and assign a new user. - Access your server via SSH or through the Terminal in cPanel
- Run the following command to create a file called pg_dump.sql
pg_dump -h 127.0.0.1 -c your_pg_db -U your_pg_user > pg_dump.sql
REPLACE: your_pg_db with the database name and your_pg_user with the database user. You can change the name of the backup file by replacing pg_dump at the very end, ensuring you keep .SQL as the extension.