Skip to content

Commit

Permalink
Moved days of backups into its own variable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWinder committed Jan 31, 2019
1 parent d44c98b commit b6f5f6d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mysql_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ user="root"
password=""
host="localhost"

# How many days would you like to keep files for?
days="30"

######################################################
##### EDITING BELOW MAY CAUSE UNEXPECTED RESULTS #####
######################################################

# Set the date
date=$(date +"%Y%m%d-%H%M")

Expand All @@ -28,5 +35,5 @@ umask 177
# Dump database into SQL file
mysqldump --lock-tables --user=$user --password=$password --host=$host $db_name > $backup_full_name

# Delete files older than 30 days
find $backup_full_name -mtime +30 -type f -delete
# Delete files older than the number of days defined
find $backup_full_name -mtime +${days} -type f -delete

0 comments on commit b6f5f6d

Please sign in to comment.