Sha256: 72308b2d731e67fce813928a5cab7e4873b61fb81fbe61f910db757cf727811b
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require_relative './postgres_helper' namespace :pg do include PostgresHelper task :dump do backup_path = configs[:backup_path] backups_enabled = configs[:backups_enabled] external_backup = configs[:external_backup] database = configs[:database] date = Time.now.to_i filename = "#{database}_#{date}.dump" unless backups_enabled puts 'dump: Backups are disabled' exit(0) end notification = Notification::Api.new commandlist = dump_cmd(config) system "mkdir -p #{backup_path}" unless Dir.exist?(backup_path) result = system(commandlist) if ENV['BACKUP_PROVIDER'].present? && external_backup && result puts "Uploading #{filename} to #{ENV['BACKUP_PROVIDER']}..." provider = Backup::Api.new begin provider.upload("#{backup_path}/#{filename}", filename.to_s, 'file') puts "#{filename} uploaded to #{ENV['BACKUP_PROVIDER']}" rescue StandardError => e puts "#{filename} upload failed: #{e.message}" end end notification.send_backup_notification(result, title, content(result, { database: database, backup_path: backup_path, filename: filename }), { date: date, backup_path: backup_path, database: database }) puts result ? "Backup created: #{backup_path}/#{filename} (#{size_str(File.size("#{backup_path}/#{filename}"))})" : 'Backup failed removing dump file' system "rm #{backup_path}/#{filename}" unless result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-ops-1.0.6 | lib/capistrano/ops/rails/lib/tasks/pg/dump.rake |