Config Library/Postgres DB Backup Workflow

Postgres DB Backup Workflow

GitHub Action
v1.0.0·1 file·YAML
33 linesEnter email to access
name: Postgres DB Backup

on:
  schedule:
    # Every Sunday at 6am UTC
    - cron: '0 6 * * 0'
  workflow_dispatch:

jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
      - name: Install PostgreSQL client
        run: sudo apt-get update && sudo apt-get install -y postgresql-client

      - name: Create backup
        env:
          DIRECT_URL: ${{ secrets.DIRECT_URL }}
        run: |
          TIMESTAMP=$(date +%Y%m%d_%H%M%S)
          pg_dump "$DIRECT_URL" \
            --format=custom \
            --no-owner \
            --no-privileges \
            --file="backup_${TIMESTAMP}.dump"
          echo "BACKUP_FILE=backup_${TIMESTAMP}.dump" >> $GITHUB_ENV

      - name: Upload backup artifact
        uses: actions/upload-artifact@v4
        with:

Showing 30 of 33 lines — enter email to view full file

How to use

Copy to .github/workflows/db-backup.yml in your repo. Add a DIRECT_URL secret with your Postgres connection string. Runs automatically every Sunday at 6am UTC.

About

A scheduled GitHub Actions workflow that runs pg_dump against your PostgreSQL database every Sunday at 6am UTC. Saves the backup as a custom-format dump file, uploads it as a GitHub artifact with 90-day retention. Can also be triggered manually. Uses DIRECT_URL secret for the connection string.

PostgreSQLBackupCI/CDFree
Free

Get notified about new configs. No spam.

Includes

  • Weekly scheduled backups (cron)
  • Manual trigger option
  • pg_dump custom format
  • 90-day artifact retention
  • Works with any Postgres (Supabase, Neon, etc.)
  • Single secret setup (DIRECT_URL)

Details

Version
1.0.0
Files
1
Language
YAML