Guest User

Untitled

a guest
Dec 11th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. readonly SCRIPT_VERSION=6
  4.  
  5. readonly SQL_USER="$1"
  6. readonly SQL_PASSWORD="$2"
  7. readonly FILE_KEEP_DAYS=4
  8. readonly DEST_DIR='sqlbackups'
  9.  
  10. mkdir -p "$DEST_DIR"
  11.  
  12. pushd "$_" >/dev/null
  13. mysqldump -u "$SQL_USER" $(test -n "$SQL_PASSWORD" && echo '-p')"$SQL_PASSWORD" --all-databases > "db-$(date '+%F_%H-%M-%S').sql"
  14. find '.' -mindepth 1 -maxdepth 1 -type f -iname '*.sql' -mtime +$FILE_KEEP_DAYS -delete
  15. popd >/dev/null
Add Comment
Please, Sign In to add comment