Class: OptimacmsBackups::Admin::BackupsController
- Inherits:
-
Optimacms::Admin::AdminBaseController
- Object
- Optimacms::Admin::AdminBaseController
- OptimacmsBackups::Admin::BackupsController
- Defined in:
- app/controllers/optimacms_backups/admin/backups_controller.rb
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/optimacms_backups/admin/backups_controller.rb', line 63 def delete f = CGI::unescape(params[:f]) @res = delete_backup(f) if @res[:res]==0 raise 'Error deleting file' end # respond_to do |format| format.html { } format.js{ } format.json{ render :json=>@res } end end |
#download ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/controllers/optimacms_backups/admin/backups_controller.rb', line 55 def download f = params[:f] path = File.join(dir_backups, f) send_data File.read(path), filename: f end |
#index ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/controllers/optimacms_backups/admin/backups_controller.rb', line 3 def index @list_backups = { 'db'=>init_list('db_backup'), 'app_files'=>init_list('app_files_backup'), 'user_files'=>init_list('user_files_backup'), } end |
#init_list(t) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/optimacms_backups/admin/backups_controller.rb', line 12 def init_list(t) res = [] # files = [] Dir["#{dir_backups}#{t}/**/*.tar"].each do |f| files << f end files = files.sort_by{ |x| File.mtime(x) }.reverse res = files.map do |f| r = {} r[:shortpath] = f.gsub /#{dir_backups}/, '' r[:path] = f r end res end |
#perform ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/optimacms_backups/admin/backups_controller.rb', line 37 def perform t = params[:t] || 'full' if t=='full' @res = perform_backup_full else @res = perform_backup(t) end respond_to do |format| format.html { } format.json{ render :json=>@res } end end |