Skip to content

Instantly share code, notes, and snippets.

@andreleoni
Last active January 30, 2024 14:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andreleoni/daa4904215ad770ca9a6d79f634179a3 to your computer and use it in GitHub Desktop.
Save andreleoni/daa4904215ad770ca9a6d79f634179a3 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
@pali7x
Copy link

pali7x commented Jun 20, 2023

thanks a lot for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment