!/bin/bash Variabel DB_USER="bani"DB_NAME="vendoretail"BACKUP_DIR="/path/to/backup"DATE=$(date +\%Y\%m\%d) Buat direktori backup jika belum ada mkdir -p "$BACKUP_DIR" Proses backup pg_dump -U $DB_USER -d $DB_NAME > "$BACKUP_DIR/${DB_NAME}_$DATE.sql" Hapus file backup yang lebih tua dari 7 hari find "$BACKUP_DIR" -type f -name "${DB_NAME}_*.sql" -mtime +7 -exec rm {} \;LOG_FILE="/path/to/backup.log" Log hasil {echo "Backup started at $(date)"pg_dump -U $DB_USER -d $DB_NAME > … Continue reading Create bash script for backup database and delete backup file
