Guest User

Untitled

a guest
Aug 12th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. FILE=`date +"%Y%m%d"`_backup.sql
  2. DBSERVER=127.0.0.1
  3. DATABASE=
  4. USER=postgres
  5. PASS=
  6.  
  7. # (2) in case you run this twice in one day, remove the previous version of the file
  8. unalias rm 2> /dev/null
  9. rm ${FILE} 2> /dev/null
  10. rm ${FILE}.gz 2> /dev/null
  11.  
  12. # (3) do the mysql database backup (dump)
  13.  
  14. # use this command for a database server on a separate host:
  15. #mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE}
  16.  
  17. # use this command for a database server on localhost. add other options if need be.
  18. pg_dump ${DATABASE} > ${FILE}
  19.  
  20. # (4) gzip the mysql database dump file
  21. gzip $FILE
  22.  
  23. # (5) show the user the result
  24. echo "${FILE}.gz was created:"
  25. ls -l ${FILE}.gz
Add Comment
Please, Sign In to add comment