pg_dump (pg_dumpall) and pg_restore tools.
To protect yourself against data loss, we recommend frequently backing up the databases you manage with Gcore Managed PostgreSQL.
1. Install external utilities
Install backup and restore utilities on your virtual or local server. Below are guides on how to do so for Ubuntu, CentOS, and Windows. Note : You must have root rights to run the commands successfully.Ubuntu 22.04
Ubuntu 22.04
- Access your Virtual Server.
-
Download the latest available updates and upgrade
apt:
- To install
pg_dumpandpg_restoretools, install the Postgres package, which includes them:
CentOS 7
CentOS 7
- Access your Virtual Server.
- Install the PostgreSQL package:
Windows
Windows
- Download the installer of the relevant PostgreSQL version.
- Run the installation process.
2. Get your credentials
To launch backup and restore tools, you need credentials (username, password, port, and dbname) to connect to the Gcore Managed Database server, where databases are stored. You can find credentials in the Customer Portal, with instructions available in our dedicated guide.
3. Back up databases
Back up a specific database
Use one of the following commands depending on your choice of backup format:- Default SQL format :
$ pg_dump -U username -W -h hostname -d database_name > database_name.sql - TAR format :
$ pg_dump -F t -U username -W -h hostname -d database_name > backup_file.tar - Custom format :
$ pg_dump -F c -U username -W -h hostname -d database_name > backup_file.dump - Directory format :
$ pg_dump -F d -U username -W -h hostname -d database_name -f backup_dir
username, hostname, and database_name, enter custom values, which you can access using our guide. For backup_file or backup_dir, specify the relevant name for the backup file or directory.
Below are some other details for the commands:
-Wprompts the password before connecting to the PostgreSQL server-Fspecifies the output format of the backup and can be followed by the following flags:cfor custom formatdfor directory formattfor tar
Back up all databases
Run the command:all_pg.sqlis the output backup nameusernameis your username from the Customer Portalhostnameis your hostname from the Customer Portal
4. Restore databases
Run the command:usernameis your username from the Customer Portalhostnameis your hostname from the Customer Portaldatabase_nameis your database name from the Customer Portalbackup_file.taris the file or directory with your backup