backup.sh

From RtMF (Quinn Storm), 1 Year ago, written in Plain Text, viewed 150 times.
URL http://paste.beautifulsunrise.org/view/64fa3dcb Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. SRCDIR="/home/rtmf/workspace/django/sunrise"
  3. PGUSER="rtmf"
  4. PGPASSWORD="testpass"
  5. PGDATABASE="test"
  6. STAGEPATH="$(mktemp -d --tmpdir backup-XXXXXXX)"
  7. DBDUMPPATH="${PGDATABASE}.psql"
  8. TARBALL="${STAGEPATH}/backup-$(date -Iseconds).tar.gz"
  9. # XXX - on many systems /tmp is tmpfs, may wish to explicitly set a tmpdir for these to avoid consuming all ram
  10. pg_dump > "${STAGEPATH}/${DBDUMPPATH}"
  11. tar -czf "${TARBALL}" -C "${STAGEPATH}" "${SRCDIR}" "${DBDUMPPATH}" 2>/dev/null
  12. rm "${STAGEPATH}/${DBDUMPPATH}"
  13. # TODO - move finished product out of STAGEPATH
  14. echo "${TARBALL}"

Reply to "backup.sh"

Here you can reply to the paste above