
Coolify is an open-source, self-hosted Platform as a Service (PaaS) solution for managing cloud infrastructure, applications, and databases. It provides built-in backup capabilities that automate database protection and enable recovery from storage failures or accidental data loss.
This article explains how to deploy a PostgreSQL database on Coolify, configure scheduled backups to S3-compatible storage, and restore the database from a backup file. It covers sample data creation, data loss simulation, and verification of the restored database.
Before you begin, you need to:
Coolify manages databases as resources within projects. Each project can contain multiple services that share networking and configuration settings.
Open your Coolify dashboard at http://SERVER-IP:8000. Replace SERVER-IP with your server's IP address. Log in with your admin account.
Under Projects, click Add to create a new project.
Name the project (such as Pg Backup) and click Continue to finish creating the project.
Click Add New Resource to create a new resource.
Under Databases, select PostgreSQL.
In the Select a PostgreSQL type screen, select PostgreSQL (the standalone option with the elephant logo, not the PostgreSQL with Supabase or pgVector variants).
Click Start to deploy the PostgreSQL database.
PostgreSQL stores data in tables that contain rows and columns. Creating sample data provides a baseline to verify that backups capture the database state correctly.
In the PostgreSQL resource dashboard, navigate to the Terminal tab.
Connect to the database using the psql client.
Output:
Create a sample table.
Insert sample data.
Query the table to verify the data insertion.
Output:
Coolify uses cron-based schedules to create database dumps and upload them to S3-compatible storage. The backup files are compressed with gzip and stored in a structured directory hierarchy.
Coolify requires an S3 storage configuration to upload backup files. The configuration stores the endpoint, credentials, and bucket name used for all backup operations.
In your S3 storage provider's dashboard, create a new bucket for database backups (for example, pg-backups). Note the bucket name, endpoint URL, access key, and secret key.
In Coolify, navigate to S3 Storages in the side menu and click Add.
Configure the S3 storage connection with the following values:
Backup Storage).ewr1.vultrobjects.com for Vultr, s3.us-east-1.amazonaws.com for AWS, or s3.wasabisys.com for Wasabi).us-east-1).Click Validate Connection & Continue to verify and save the configuration.
Each PostgreSQL service in Coolify has its own backup configuration. The schedule determines when backups run, and the storage destination determines where files are saved.
Navigate to the PostgreSQL resource dashboard and select the Backup tab.
Click Add to create the backup schedule.
In the schedule creation form, configure the following:
*/1 * * * * to run every minute for testing.
Click the schedule you created, then under Settings, check the Backup All Databases checkbox and save.
Without this option enabled, the schedule backs up only the default postgres database. Additional databases on the server are excluded from the backup.
Wait one minute for the first scheduled backup to run. Open the S3 bucket in your provider's dashboard and verify that the backup file appears.
Dropping a table removes both the table structure and all data it contains. Use this operation to simulate the type of accidental data loss that backups protect against.
Navigate to the Terminal tab in the PostgreSQL resource dashboard. Connect to the database.
Drop the users table to delete all sample data.
Attempt to query the table to confirm the data loss.
Output:
Coolify's restore process downloads the backup file from S3 storage, decompresses it, and executes the SQL statements to recreate the database objects and data.
Open the S3 bucket in your provider's dashboard and locate the backup file. Coolify stores backups in a path structure like data/coolify/backups/databases/.... Click the backup file (for example, pg-dump-all-1771242721.gz) to view its details.
Copy the object key (the path portion without the bucket name). For example, if the full path is:
The object key is:
In the PostgreSQL resource dashboard, navigate to the Configuration tab and scroll to the Import Backup section.
Under Choose Restore Method, click Select from S3.
Under Restore from S3, select the S3 storage you configured earlier (for example, Backup Storage).
Under S3 File Path, enter the object key you noted earlier.
For PostgreSQL servers with multiple databases, enable the Backup includes all databases checkbox to restore all databases from the backup file.
Click Check File. A success message confirms the file is accessible. Click Restore Database from S3 to proceed.
Type the case-sensitive confirmation text exactly as shown and click Continue.
Enter your Coolify password in the prompt, then click Confirm.
Querying the restored data confirms that the backup file captured a complete and consistent snapshot of the database state.
In the Terminal tab, connect to the database using psql.
Query the users table to verify the restoration.
Output:
The output matches the original data, confirming the backup captured the complete database state before the table was dropped.
You have configured automated PostgreSQL backups to S3-compatible storage in Coolify, created sample data, simulated data loss, and restored the database from the backup file. This configuration provides data protection against accidental deletions and storage failures. For more information about Coolify's backup features, visit the official Coolify documentation.
0 Comments
Be the first to comment and share your perspective with the community.