backup-financialdb.sh 543 B

1234567891011121314
  1. #!/bin/sh
  2. echo "$(date) backup financialdb start"
  3. export PGPASSWORD='Finance@unicom23'
  4. backup_dir=/backup/postgres/financialdb/$(date +%Y%m)/$(date +%Y%m%d)/$(date +%Y%m%d%H%M%S)
  5. mkdir -p "${backup_dir}"
  6. host='172.16.107.5'
  7. port='5432'
  8. username='finance'
  9. dbname='financialdb'
  10. jobs='16'
  11. echo "pg_dump -h ${host} -p ${port} -U ${username} -d ${dbname} -v -O -Fd -j ${jobs} -Z9 -f ${backup_dir}"
  12. pg_dump -h "${host}" -p "${port}" -U "${username}" -d "${dbname}" -v -O -Fd -j "${jobs}" -Z9 -f "${backup_dir}"
  13. echo "$(date) backup financialdb end"