Skip to content

Harden mysqlbackup.sh script #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2013
Merged

Conversation

omalashenko
Copy link
Contributor

  • mysql::backup backuprotate parameter sets the number of backups to keep, default is 30.
  • Use bash in mysqlbackup.sh to get exit status of mysqldump when piped to bzip2. Unfortunately there is no easy portable way to do that.
  • Only delete old backups when current backup finished successfully.
  • Try hard not to delete files that we didn't create (i.e. README or other backups).


##### STOP CONFIG ####################################################
PATH=/usr/bin:/usr/sbin:/bin:/sbin

find $DIR -mtime +30 -exec rm -f {} \;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some folks are tight on space and it is better to delete before writing a dump that fills the filesystem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is good to have at least 1 good backup at any point in time, which means not deleting it before new backup has succeeded.

Secondly, at the moment there is non configurable default of 30 days worth of backups to keep. By introducing backuprotate parameter we give people tight on disk space some breathing space.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All I am saying is to give people an option to change the default behaviour. Do not force it upon them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think generally I agree with razorsedge, this would be pretty easy to handle with a toggle option. Maybe even just something as horribly named as $delete_before_dump = false as a default and then a quick if/else in the template to determine ordering. Would you be willing to go that route?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will update pull request when ready.

@apenney
Copy link
Contributor

apenney commented Jul 4, 2013

Thanks for the improvements! We're almost done, but this PR needs rebasing off master so that it can be cleanly merged without conflicts. If you can fix that, I'll merge this one in for you. :)

(If you're feeling brave, and feel up to updating mysql_backup_spec.rb to add the new parameter and make sure the "verify_contents()" content is still OK I'd appreciate it. If not I'll do this after I merge. We're looking to release 0.8.0 of this module tomorrow afternoon so hopefully we can get this one in on time to be released.)

 * mysql::backup backuprotate parameter sets the number of backups to keep,
   default is 30.

 * Use bash in mysqlbackup.sh to get exit status of mysqldump when piped to
   bzip2. Unfortunately there is no easy portable way to do that.

 * Only delete old backups when current backup finished successfully.

 * Try hard not to delete files that we didn't create (i.e. README or other
   backups).
$delete_before_dump controls whether old backups to be removed before
creating new one.
@omalashenko
Copy link
Contributor Author

Rebased to master. I'll have a look at the spec file later.

@apenney
Copy link
Contributor

apenney commented Jul 5, 2013

I left omalashenko#1 for you which covers the spec changes. If you can merge that then I'll merge this!

Tweak spec file to account for days of rotation.
apenney added a commit that referenced this pull request Jul 9, 2013
Harden mysqlbackup.sh script
@apenney apenney merged commit 926e94a into puppetlabs:master Jul 9, 2013
pmcmaw pushed a commit to pmcmaw/puppetlabs-mysql that referenced this pull request Mar 3, 2021
…val_of_inappropriate_terminology

(IAC-1010) - Removal of Inappropriate Terminology
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants