Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Create user backup
  2. From him will run scripts
  3.  
  4. CREATE USER 'backup'@'localhost' IDENTIFIED BY 'user_password';
  5. GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup'@'localhost';
  6. GRANT LOCK TABLES ON *.* TO 'backup'@'localhost';
  7.  
  8. Create directory for backup
  9. mkdir /backup/mysql/
  10.  
  11. Create bash script database.sh with content:
  12. -----
  13. #!/bin/bash
  14.  
  15. USER="backup"
  16. PASS="user_password"
  17.  
  18. NOW="$(date +"%Y%m%d")"
  19.  
  20. /usr/bin/mysqldump -u $USER -p$PASS -A | /bin/gzip > /backup/mysql/all--$NOW.sql.gz
  21. -----
  22.  
  23. Making a file executable
  24. chmod +x database.sh
  25.  
  26. And run file database.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement