- #!/bin/bash
- #Source external configuration
- . $1
- today=$(date +"%Y-%m-%d_%H-%M")
- filename="${today}_${dbName}_Backup.sql"
- fullBackupFileName="${backupFilepath}${filename}"
- #Backup Job
- docker exec -i ${dockerContainerName} /bin/bash -c "PGPASSWORD=${dbpasswd} pg_dump --username ${dbUser} ${dbName}" > $fullBackupFileName
- #Backup rotation - Delete everything older than rotationDays
- find $backupFilepath -type f -mtime +$rotationDays -name '*.sql' -execdir rm -- '{}' \;
|