xxxxxxxxxx
#!/bin/bash
# Set the backup directory
BACKUP_DIR="/path/to/backup/directory"
# Set the database credentials
PGHOST="localhost"
PGPORT="5432"
PGUSER="your_username"
PGPASSWORD="your_password"
DATABASE="your_database"
# Generate the backup file name with the current date
BACKUP_FILE="$BACKUP_DIR/$(date +%Y-%m-%d).sql"
# Execute the pg_dump command to create the backup
pg_dump -h $PGHOST -p $PGPORT -U $PGUSER -W $PGPASSWORD $DATABASE > $BACKUP_FILE