Skip to content

Instantly share code, notes, and snippets.

@pali7x
Forked from andreleoni/automatic_crontab.sh
Created January 30, 2024 14:27
Show Gist options
  • Save pali7x/3eb76e109ebea46d5c015bc8d36f0790 to your computer and use it in GitHub Desktop.
Save pali7x/3eb76e109ebea46d5c015bc8d36f0790 to your computer and use it in GitHub Desktop.
automatic crontab for automatic mysql/mariadb backup/mysqldump on linux
# 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