𝗛𝗼𝘄 𝘁𝗼 𝗕𝗮𝗰𝗸𝘂𝗽 𝗮𝗻𝗱 𝗥𝗲𝘀𝘁𝗼𝗿𝗲 𝗖𝗼𝗼𝗹𝗶𝗳𝘆 𝗶𝗻 𝟭𝟮 𝗠𝗶𝗻𝘂𝘁𝗲𝘀

Your server feels safe today. You spent hours setting up Coolify. You host your own apps, databases, and blogs. You feel in control.

Then a disaster happens. Your VPS provider shuts down your region. You run a wrong command. The server dies.

If you have no backups, you lose everything. This guide prevents that. You can set up automated backups and a full restore in 12 minutes.

Step 1: Set up S3 Storage

Coolify needs a place to store backups. Use S3-compatible storage. Cloudflare R2 is a great choice because it has zero egress fees.

You need these details from your storage provider:

  • Endpoint
  • Region
  • Access Key
  • Secret Key
  • Bucket Name

In Coolify, go to the S3 Storage tab. Add your details and click Validate Connection.

Step 2: Enable Automated Backups

Go to Settings and then Backup.

  • Turn on S3 Backup.
  • Turn on Backup.
  • Select your S3 storage source.
  • Set the frequency to Daily.

Run one manual backup immediately. Check your S3 bucket to confirm the file exists.

Step 3: Save Your APP_KEY

This is the most important step. Coolify encrypts your data. If you lose this key, your backup is useless.

SSH into your server and run: cat /data/coolify/source/.env

Find the line starting with APP_KEY. Copy this value. Save it in a password manager. Do not skip this.

Step 4: Restore to a New Server

If your server dies, follow these steps on your new VPS:

  1. Install Coolify using the standard curl command.
  2. Download your .pgdump file from your S3 bucket to the new server.
  3. Run the restore command:

sudo docker exec -i coolify-db pg_restore --username coolify --verbose --dbname coolify < /path/to/your-backup.pgdump

You might see warnings about existing tables. Ignore them. It still works.

Step 5: Fix the 500 Error

After restoring, you might see a 500 error when clicking apps. This happens because the new server has a different APP_KEY.

To fix this:

  • Open your new .env file: nano /data/coolify/source/.env
  • Add this line: APP_PREVIOUS_KEYS=base64:your-old-app-key
  • Save and restart Coolify using the install script.

Now your old data is readable again.

Summary Checklist:

  • Set up S3 storage.
  • Enable daily backups.
  • Save your APP_KEY safely.
  • Test a manual backup.

Self-hosting gives you control. Backups give you peace of mind.

Source: https://dev.to/dev-arafat-alim/how-to-backup-and-restore-coolify-in-12-minutes-before-your-server-dies-on-a-friday-night-254p