Created
November 16, 2016 12:51
-
-
Save maztch/fcb1404b11316415cd94d214cb5f1cba to your computer and use it in GitHub Desktop.
database backup script
This file contains hidden or 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 | |
# this script makes a database backup and delete files older than 15 days | |
# to make script execuable use 'chmod +x backupdb.sh' | |
# change username, password and database for yours and modify your path if needed | |
mysqldump -u [username] -p[password] [database_name] > /root/backups/db_backup_`date +"%Y%m%d%H%M%S"`.sql | |
# change '-mtime +15' to keep more or less days (and path if needed) | |
find /root/backups/* -mtime +15 -exec rm {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment