Last active
December 19, 2015 21:39
Revisions
-
r3bo0t renamed this gist
Jul 17, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
r3bo0t renamed this gist
Jul 17, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
r3bo0t created this gist
Jul 17, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ require 'mysql_s3_backup' class MysqlS3Dumper attr_accessor :config class MysqlS3Backup::Backup def full(name=make_new_name) lock do # When the full backup runs it delete any binary log files that might already exist # in the bucket. Otherwise the restore will try to restore them even though they’re # older than the full backup. @bucket.delete_all @bin_log_prefix with_temp_file do |file| puts file @mysql.dump(file) @bucket.store(dump_file_name(name), file) @bucket.copy(dump_file_name(name), dump_file_name("latest")) @bucket.keep_last_five end end end end class MysqlS3Backup::Bucket def keep_last_five puts @name puts "coming to bucket" all_backups = AWS::S3::Bucket.objects(@name) while all_backups.count > 6 AWS::S3::Bucket.objects(@name).first.delete all_backups = AWS::S3::Bucket.objects(@name) end end end def initialize @config = MysqlS3Backup::Config.from_yaml_file(File.dirname(__FILE__) + "/../config/s3_mysql.yml") end end