Class: LitestreamRails::RestorationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- LitestreamRails::RestorationsController
- Defined in:
- app/controllers/litestream_rails/restorations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /restorations.
Instance Method Details
#create ⇒ Object
POST /restorations
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/litestream_rails/restorations_controller.rb', line 4 def create database = params[:database].remove("[ROOT]/") dir, file = File.split(database) ext = File.extname(file) base = File.basename(file, ext) now = Time.now.utc.strftime("%Y%m%d%H%M%S") backup = File.join(dir, "#{base}-#{now}#{ext}") Litestream::Commands.restore(database, async: false, **{"-o" => backup}) redirect_to root_path, notice: "Restored to <code>#{backup}</code>." end |