name: Backups / PG_Base

on:
  schedule:
    - cron: 0 3 * * *

jobs:
  pg_basebackup:
    name: PG Base Backup
    runs-on: app_host
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
      AWS_DEFAULT_REGION: us-west-1
    steps:
      - working-directory: /opt/app/skyderby
        run: docker-compose exec -T db /bin/bash -c "pg_basebackup --format=tar -D - --gzip --wal-method=fetch -U skyderby" | aws s3 cp - s3://pg-backup.skyderby.ru/pg_backup.tar.gz
  cleanup_wal_files:
    name: Cleanup WAL files
    runs-on: app_host
    needs:
      - pg_basebackup
    steps:
      - name: Remove old WAL archive files
        working-directory: /opt/app/skyderby
        run: |
          docker-compose exec db find /wal_archive -type f -name "*.backup" -mtime +$((60*48)) -exec /bin/bash -c 'pg_archivecleanup -d /wal_archive $(basename  "$1")' - {} \;
      - name: Remove backup labels
        working-directory: /opt/app/skyderby
        run: |
          docker-compose exec db find /wal_archive -type f -name "*.backup" -mmin +$((60*48)) -print -exec rm '{}' \;

name: Backups / PG_Base

on:
  schedule:
    - cron: 0 3 * * *

jobs:
  pg_basebackup:
    name: PG Base Backup
    runs-on: app_host
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
      AWS_DEFAULT_REGION: us-west-1
    steps:
      - working-directory: /opt/app/skyderby
        run: docker-compose exec -T db /bin/bash -c "pg_basebackup --format=tar -D - --gzip --wal-method=fetch -U skyderby" | aws s3 cp - s3://pg-backup.skyderby.ru/pg_backup.tar.gz
  cleanup_wal_files:
    name: Cleanup WAL files
    runs-on: app_host
    needs:
      - pg_basebackup
    steps:
      - name: Remove old WAL archive files
        working-directory: /opt/app/skyderby
        run: |
          docker-compose exec -T db find /wal_archive -type f -name "*.backup" -mmin +$((60*48)) -exec /bin/bash -c 'pg_archivecleanup -d /wal_archive $(basename  "$1")' - {} \;
      - name: Remove backup labels
        working-directory: /opt/app/skyderby
        run: |
          docker-compose exec -T db find /wal_archive -type f -name "*.backup" -mmin +$((60*48)) -print -exec rm '{}' \;

Fix "the input device is not a TTY"
Fix "the input device is not a TTY"
