#!/bin/bash
#stgresql backup
#option
delDay=$(date -d '1 month ago' +%Y_%m_%d)
backupDay=$(date +%Y_%m_%d)
backupName="${backupDay}.sql"
path='/backup/postgresql/'
user='postgres'
containerID='23d387e1af4c'
#delete the file one month ago
rm -rf ${path}${delDay}.sql
#backup
docker exec ${containerID} pg_dumpall -U ${user} > ${path}${backupDay}.sql
if [ $? -eq 0 ]
then
echo "success"
fi