How to use tar in ruby on rails?

So I want to make this script to also compress the files in /home/git/gitlab/public/uploads/files_which_should_be_compressed as a tar file and also to move this tar file to /home/git/gitlab/tmp/backups/uploads for a backup. Here is the script I am currently using for the uploads:

module Backup
class Uploads

attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir    def initialize    @app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads'))    @backup_dir = Gitlab.config.backup.path    @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads')  end    # Copy uploads from public/uploads to backup/uploads  def dump    FileUtils.mkdir_p(backup_uploads_dir)    FileUtils.cp_r(app_uploads_dir, backup_dir)  end    def restore    backup_existing_uploads_dir      FileUtils.cp_r(backup_uploads_dir, app_uploads_dir)  end    def backup_existing_uploads_dir    timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}")      if File.exists?(app_uploads_dir)      FileUtils.mv(app_uploads_dir, timestamped_uploads_path)   end 

end end end

Replay

Category: tar Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.130 (s). 12 q(s)