Backup and Restore Your Coolify Instance
This guide will show you how to back up your Coolify instance and restore it on a new server.
There are two methods to create backups:
- S3 Backup: Use S3-compatible storage to automatically save backups.
- Manual Backup: Trigger a backup manually from the Coolify dashboard.
If you use S3-compatible storage, simply download the backup file from your S3 provider and transfer it to your new server.
The rest of this guide will focus on the manual backup method, which is ideal for most users.
1. Create a Manual Backup
Go to Backup Page on Dashboard:
In your Coolify dashboard, click on Settings and select the Backup tab to view your database and backup settings.Trigger a Backup:
Click on the Backup Now button. This will start the backup process in the background.Download or Copy Backup Location:
Once the backup is complete, you will see a Download button and a location path in the UI.- Download: Saves the backup file to your local computer.
- Copy Path: You can use this path with a tool like SCP to transfer the backup file directly to your new server.
Note:
If you are using S3-compatible storage for backups, download the backup file from your S3 provider instead
2. Retrieve Your APP_KEY
Before you restore the backup, you need to obtain the APP_KEY
from your current Coolify instance. This key is used to decrypt your data during restoration.
Open the Terminal in Coolify:
Access the Terminal tab in the dashboard and connect tolocalhost
.Navigate to the Data Directory:
shcd /data/coolify/source
View the Environment File:
Run the following command to display the contents of the.env
file:shcat .env
Copy the value of
APP_KEY
and save it securely. This key is important for the restoration process.
IMPORTANT**
Save this APP_KEY
safely. Without it, you cannot restore your backup.
3. Prepare Your New Server
Set up your new server where you will restore your Coolify instance.
Install a Fresh Coolify Instance:
Follow the installation instructions for Coolify on your new server. This could be on a VPS, WSL, or any other environment.Verify the Installation:
Access your new Coolify instance on your browser. A fresh installation will show the registration page, indicating that no data exists yet.
4. Transfer and Restore the Backup
Transfer the Backup File:
Copy the backup file you created to the new server. You can do this via SCP, FTP, or any other secure file transfer method.Run the Restore Command:
Use the PostgreSQL restore tool to import your backup into the database container.shdocker exec -it coolify-db pg_restore --verbose --clean --no-acl --no-owner -U coolify -d coolify < /path/to/your_backup_file
You have to replace
/path/to/your_backup_file
with the path of your backup file on the server.Note:
Some warnings about existing foreign keys or sequences might appear; these can usually be ignored if the base structure remains intact.
5. Update Environment Settings for Restoration
After restoring the backup, update your environment configuration to allow the new instance to use the old data.
Access the Data Directory:
Navigate to the directory where your environment files are stored:shcd /data/coolify/source
Edit the Environment File:
Open the.env
file with your preferred text editor:shnano .env
Add the Previous APP Key:
Add a new environment variable calledAPP_PREVIOUS_KEYS
and paste theAPP_KEY
you saved earlier:yamlAPP_PREVIOUS_KEYS=your_previous_app_key_here
Save and exit the editor.
6. Restart Coolify
To apply the restored backup and updated environment settings, restart your Coolify instance using the install script.
Run the Installation Script:
Re-run the Coolify installation command:shcurl -fsSL https://cdn.coollabs.io/coolify/install.sh | sudo bash
Verify the Restoration:
Visit your Coolify dashboard URL and log in with the same credentials from your previous instance. Your projects, deployments, and settings should now be restored.
Troubleshooting
500 Error on Login or Project Access:
Double-check that theAPP_PREVIOUS_KEYS
variable is correctly set in your.env
file.Permission Denied Errors:
If you encounter permission issues while accessing directories, change the ownership of the/data/coolify
directory. Since Coolify uses the root user account, ensure that the ownership is set to root:shsudo chown -R root:root /data/coolify