Created
December 1, 2020 07:56
-
-
Save willnode/11614dd1e8bfcfd7c4619435e64564a3 to your computer and use it in GitHub Desktop.
Bash script to backup MySQL data efficiently
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
timestamp=`date +%Y%m%d-%H` | |
tar -cf /root/mysqlb/backup-`echo $timestamp`.tar /var/lib/mysql | |
gzip -1 /root/mysqlb/backup-`echo $timestamp`.tar | |
find /root/mysqlb/ -type f -mtime +7 -name '*.gz' -print0 | xargs -r0 rm -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment