Orbit/app/jobs/backup_server.rb

18 lines
663 B
Ruby
Raw Normal View History

class BackupServer
@queue = :high
def self.perform()
#CronMail.time_check("Going to backup Orbit").deliver
dbhost = Mongoid.config.database.connection.primary.join ':'
dbname = Mongoid.config.database.name
2013-04-24 11:21:11 +00:00
archive_db_list_path = OrbitSystemPreference::ArchiveDbListPath
dbdirectory = "#{Rails.root}/tmp/#{dbname}-"+Time.now.strftime("%Y-%m-%d-%H-%M")
%x[mongodump -h #{dbhost} -d #{dbname} -o #{dbdirectory} ]
2013-04-24 11:21:11 +00:00
%x[rm #{archive_db_list_path}]
%x[ls #{Rails.root}/tmp/#{dbname}* | du -h --max-depth=1 --block-size=1M |sort -h >> #{archive_db_list_path}]
2013-05-14 02:29:11 +00:00
OrbitLogger.info "DB backup done Path:#{dbdirectory}"
2013-04-24 11:21:11 +00:00
end
end