namespace :db do

  desc "Zálohování provozní databáze"

  task :backup => :environment do
    backup_dir = ENV['DIR'] || File.join(Rails.root, 'db', 'backup')

    source = File.join(Rails.root, 'db', "production.db")
    dest = File.join(backup_dir, "production.backup")

    makedirs backup_dir
    sh "sqlite3 #{source} .dump > #{dest}"
  end
end
