-
-
Save pali7x/3eb76e109ebea46d5c015bc8d36f0790 to your computer and use it in GitHub Desktop.
automatic crontab for automatic mysql/mariadb backup/mysqldump on linux
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
# Access crontab -e | |
crontab -e | |
# Create a CRON like this | |
30 10 * * * ~/autobackup.sh | |
# Create autobackup file | |
touch ~/autobackup.sh | |
# autobackup.sh content | |
#!/bin/bash | |
sudo mysqldump wordpress > db_backup/db_$(date +%m-%d-%Y_%H-%M-%S).sql | |
sudo find db_backup -mtime +10 -type f -delete | |
# Set file permission | |
chmod +x ~/autobackup.sh | |
# Set mysqlddump default user to /etc/mysql/my.cnf | |
[mysqldump] | |
user = user | |
password = your_password | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment