Guest User

Untitled

a guest
Oct 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #!/bin/sh
  2. PGBIN_DIR=/usr/bin/
  3. PSQL="${PGBIN_DIR}/psql -w --username=postgres"
  4. PG_DUMPALL="${PGBIN_DIR}/pg_dumpall --username=postgres"
  5. PG_DUMP="${PGBIN_DIR}/pg_dump --username=postgres"
  6. #
  7. CRON_DIR=/home/postgres/cron
  8. #DUMP_DIR=${HOME}/cron
  9. #DUMP_DIR=/data/db/backups
  10. DUMP_DIR=/data/postgres/backup
  11. PGDATA_DIR=/data/db/pgdata
  12.  
  13. ###################################
  14. #DATABASES=`${PSQL} -A -t -q << HIERO
  15. #select datname from pg_database WHERE datname NOT IN ( 'template0' )
  16. #AND datname NOT LIKE 'pub_%' \g
  17. #HIERO`
  18. DATABASES="intspecinf_ont"
  19. DAG="120601"
  20.  
  21. ############################################
  22. ## Dumpen van tablespacedefinities
  23. ## Dumpen van users en rollen
  24. ## -t := tablespacedefinities only
  25. ## -r := Roles only
  26. ## NB: --host optie gebruikt een connectie via IP (loopback)
  27. ## ; zonder de -host-vlag gaat de connectie over een unix-domain socket.
  28. ## Dit wordt hier gebruikt om password-prompts te vermijden (!)
  29. ## pg_hba.conf heeft een allow voor locale postgres. Dit is een veiligheids-
  30. ## risico, maar *als* een intruder postgres-shell-access mocht krijgen
  31. ## is er sowieso al een probleem.
  32. ############################################
  33.  
  34. mkdir -p ${DUMP_DIR}/${DAG}
  35.  
  36. #####################################################################
  37. ## -o := maintain oids
  38. ## -C := create before use
  39. ## -s := schema only
  40. ## -a := data only
  41. ## -D / -d := insert...VALUES() instead of copy...FROM (-D=with column names)
  42. ## (dit conflicteert met -o --oids !!!!)
  43. ## --format=c
  44. #####################################################################
  45.  
  46. for d in ${DATABASES}; do
  47. echo "Database ${d}:${DUMP_DIR}/${DAG}/${d}_..."
  48. ${PG_DUMP} --disable-triggers --create --schema-only \
  49. -f ${DUMP_DIR}/${DAG}/${d}_schemas.dmp ${d}
  50. ${PG_DUMP} --disable-triggers --data-only \
  51. -f ${DUMP_DIR}/${DAG}/${d}_dataonly.dmp ${d}
  52. echo "Klaar met database $d."
  53. done
  54.  
  55. exit 0
  56. #####################################################################
  57. ## Eof
  58. #####################################################################
Add Comment
Please, Sign In to add comment