Skip to content

Instantly share code, notes, and snippets.

@dsifat
Created August 19, 2023 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsifat/18727ac4646e975a537598a2507399d1 to your computer and use it in GitHub Desktop.
Save dsifat/18727ac4646e975a537598a2507399d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set the database name and the backup file name
DB_NAME="database"
BACKUP_FILE="database_backup.sql"
date=date=$(date '+%Y-%m-%d')
# Set the username and password for the database
DB_USERNAME="username"
DB_PASSWORD="password"
# Dump the database to a file
pg_dump -U $DB_USERNAME -W $DB_NAME > $BACKUP_FILE_${date}
echo "Database has been done on ${date}" >> /tmp/backup_log_${date}.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment