Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- readonly SCRIPT_VERSION=6
- readonly SQL_USER="$1"
- readonly SQL_PASSWORD="$2"
- readonly FILE_KEEP_DAYS=4
- readonly DEST_DIR='sqlbackups'
- mkdir -p "$DEST_DIR"
- pushd "$_" >/dev/null
- mysqldump -u "$SQL_USER" $(test -n "$SQL_PASSWORD" && echo '-p')"$SQL_PASSWORD" --all-databases > "db-$(date '+%F_%H-%M-%S').sql"
- find '.' -mindepth 1 -maxdepth 1 -type f -iname '*.sql' -mtime +$FILE_KEEP_DAYS -delete
- popd >/dev/null
Add Comment
Please, Sign In to add comment