!/usr/bin/env bash
rm -rf /tmp/pg_dump/*
mkdir -p /tmp/pg_dump/$(date +"%Y%m%d%H")
mkdir -p /home/backup/pg_dump
export PGPASSWORD=passwd
set PGCLIENTENCODING=UTF8
pg_dumpall -U postgres -f /tmp/pg_dump/$(date +"%Y%m%d%H")/$(date +"%Y%m%d%H") >> /tmp/pg_dump/$(date +"%Y%m%d%H")/$(date +"%Y%m%d%H").log 2>&1
tar zcvfP /home/backup/pg_dump/$(date +"%Y%m%d%H").tar.gz /tmp/pg_dump/$(date +"%Y%m%d%H")