Skip to content
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

Backup on MySQL DB slave if it is available #249

Closed

Conversation

kaspergrubbe
Copy link
Contributor

@kaspergrubbe kaspergrubbe commented Aug 10, 2017

This fixes #218 .

Forever cron

I also think that the old code included a "race"-condition.

If node.dna['backup_window'] was at some point positive, and then turned off, the old cronjob was never deleted.

if node.dna['backup_window'] != 0 && ['db_master','solo'].include?(node.dna['instance_role'])
  encryption_command = @encryption_command
  backup_command = "eybackup -e mysql #{encryption_command} >> /var/log/eybackup.log 2>&1"

  cron "mysql" do
    command backup_command
    month   '*'
    weekday '*'
    day     '*'
    hour    node['backup_hour']     # this attribute is set by ey-base/attributes/snapshot_and_backup_intervals.rb
    minute  node['backup_minute']
  end
end

Postgresql

I also simplified the Postgresql code.

Request for comments

Let me know what you think.

is_db_slave = 'db_slave' == node.dna['instance_role']
is_first_slave = node.dna['db_slaves'].first == (node['ec2'] && node['ec2']['local_hostname'] ? node['ec2']['local_hostname'] : hostname.stdout)

if has_backups_enabled && (db_slaves_available && is_db_slave && is_first_slave || !db_slaves_available && is_db_master_or_solo)
Copy link
Contributor

Choose a reason for hiding this comment

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

is_db_slave is redundant in this test - we can just check:

if has_backups_enabled && (db_slaves_available && is_first_slave || !db_slaves_available && is_db_master_or_solo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been changed.

@mage2k
Copy link
Contributor

mage2k commented Sep 15, 2017

Closing this as we're not going to automatically move backups to MySQL db_slaves as that could adversely affect many existing environments. Once we get our current back log of other Pull Requests merged and released we will be making where the backup runs configurable via an attribute in either the ey-backup or mysql cookbook.

@mage2k mage2k closed this Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port eybackup_slave recipe
3 participants