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

[YT-CC-1189] Overlay ey-backup attributes to move MySQL backup to DB slave. #280

Open
wants to merge 1 commit into
base: next-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cookbooks/ey-backup/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
default['db_backup']['mysql']['backup_slave'] = false
# default['db_backup']['mysql']['db_slave_name'] = 'backup'
8 changes: 7 additions & 1 deletion cookbooks/ey-backup/recipes/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
end
end

if node.dna['backup_window'] != 0 && ['db_master','solo'].include?(node.dna['instance_role'])
is_backup_instance = if node['db_backup']['mysql']['backup_slave']
Copy link
Contributor

Choose a reason for hiding this comment

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

It took me a minute to get my head around this. Would it be clearer to assign is_backup_instance explicitly in the two different cases, rather than assigning the result of the if statement? (It would have been clearer to me :D )

['db_slave'].include?(node.dna['instance_role']) && node['db_backup']['mysql']['db_slave_name'] == node['dna']['name']
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 this change means that the customer must specify the name of the replica which should run the backup. What happens if they don't? What happens if the name they specify doesn't exist? Is it possible to gracefully fall back to the same behaviour as PostgreSQL in either of those cases, and just choose the first replica?

(If so then it would be good to have this behaviour for both, and simply set default['db_backup']['mysql']['backup_slave'] true for PostgreSQL while leaving default['db_backup']['mysql']['db_slave_name'] empty by default.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Obviously we would rename the variables if we were making this more general.
Perhaps:
default['db_backup']['run_backup_on_replica']
default['db_backup']['backup_replica_name']

else
['db_master','solo'].include?(node.dna['instance_role'])
end

if node.dna['backup_window'] != 0 && is_backup_instance
encryption_command = @encryption_command
backup_command = "eybackup -e mysql #{encryption_command} >> /var/log/eybackup.log 2>&1"

Expand Down
3 changes: 3 additions & 0 deletions custom-cookbooks/db-backup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DB Backup in Slave (MySQL only)

This example contains a complete `cookbooks/` directory that you can use on the stable-v5 stack that will override the backup location of MySQL, moving it from the DB Master to a DB Slave named "backup".
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
default['db_backup']['mysql']['backup_slave'] = true
default['db_backup']['mysql']['db_slave_name'] = 'backup'