Skip to content

Instantly share code, notes, and snippets.

@nimdasx
Last active May 30, 2024 15:21
Show Gist options
  • Save nimdasx/609a675d018cf4ce4abf2e9a8708dd11 to your computer and use it in GitHub Desktop.
Save nimdasx/609a675d018cf4ce4abf2e9a8708dd11 to your computer and use it in GitHub Desktop.
mysql-backup.sh
prefix=$(hostname)
host=0.0.0.0
user=root
pass=xxx
port=3306
databases="xxx yyy"
lokasi="./"
for database in $databases
do
echo $database
mysqldump -h$host -u$user -p$pass -R -P$port $database | pv -W -s 100m | gzip > $lokasi$prefix-$database-$(date +"%Y-%m-%d_%H-%M-%S").sql.gz
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment