aiflow / backup.sh
AZLABS's picture
Update backup.sh
3565651 verified
raw
history blame contribute delete
470 Bytes
#!/bin/bash
# Use environment variable PGPASSWORD for backup
export PGPASSWORD="$DB_POSTGRESDB_PASSWORD"
# Backup database to a fixed file name, overwriting the previous backup
pg_dump -U "$DB_POSTGRESDB_USER" -d "$DB_POSTGRESDB_DATABASE" -F c -b -v -f "${WORKDIR}/backups/backup.dump"
# Check if backup was successful
if [ $? -eq 0 ]; then
echo "Database backup successful"
else
echo "Database backup failed"
fi
# Clear environment variable
unset PGPASSWORD