lib/db_rotator.rb in db-rotator-0.0.3 vs lib/db_rotator.rb in db-rotator-0.1.0

- old
+ new

@@ -4,16 +4,23 @@ TIME_FORMAT = "%Y%m%d" def initialize(config) @config = config.config @schemas = [] + populate_schemas + rescue + on_failure $! end def rotate refresh update_db_yaml + on_success + + rescue + on_failure $! end def refresh download_dump import @@ -25,9 +32,21 @@ import_dump populate_schemas end private + + def on_success + bash_exec "#{@config[:on_success]}" if @config[:on_success] + end + + def on_failure(err) + if @config[:on_failure] + bash_exec "#{@config[:on_failure]} #{err.class.name} '#{err.message}'" + else + raise err + end + end def download_dump verbose_message "Downloading dump..." bash_exec "rm -f #{local_dump_path}" bash_exec "#{@config[:scp_command]} #{local_dump_path}"