2012-07-09 17:45:43 -04:00
|
|
|
require 'active_record/fixtures'
|
|
|
|
|
|
|
|
namespace :gitlab do
|
2012-12-20 14:17:09 -05:00
|
|
|
namespace :backup do
|
2012-09-26 07:18:10 -04:00
|
|
|
# Create backup of GitLab system
|
|
|
|
desc "GITLAB | Create a backup of the GitLab system"
|
2013-05-05 10:01:10 -04:00
|
|
|
task create: :environment do
|
2012-12-23 15:15:25 -05:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
Rake::Task["gitlab:backup:db:create"].invoke
|
|
|
|
Rake::Task["gitlab:backup:repo:create"].invoke
|
2013-04-10 08:41:47 -04:00
|
|
|
Rake::Task["gitlab:backup:uploads:create"].invoke
|
2012-07-09 17:45:43 -04:00
|
|
|
|
2013-08-05 05:26:33 -04:00
|
|
|
backup = Backup::Manager.new
|
|
|
|
backup.pack
|
|
|
|
backup.cleanup
|
|
|
|
backup.remove_old
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2012-09-26 07:18:10 -04:00
|
|
|
# Restore backup of GitLab system
|
2012-07-09 17:45:43 -04:00
|
|
|
desc "GITLAB | Restore a previously created backup"
|
2013-05-05 10:01:10 -04:00
|
|
|
task restore: :environment do
|
2012-12-23 15:15:25 -05:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2013-08-05 05:26:33 -04:00
|
|
|
backup = Backup::Manager.new
|
|
|
|
backup.unpack
|
2012-07-09 17:45:43 -04:00
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
Rake::Task["gitlab:backup:db:restore"].invoke
|
|
|
|
Rake::Task["gitlab:backup:repo:restore"].invoke
|
2013-04-10 08:41:47 -04:00
|
|
|
Rake::Task["gitlab:backup:uploads:restore"].invoke
|
2013-04-18 06:27:52 -04:00
|
|
|
Rake::Task["gitlab:shell:setup"].invoke
|
2012-07-09 17:45:43 -04:00
|
|
|
|
2013-08-05 05:26:33 -04:00
|
|
|
backup.cleanup
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
namespace :repo do
|
2013-05-05 10:01:10 -04:00
|
|
|
task create: :environment do
|
2012-12-31 11:22:44 -05:00
|
|
|
puts "Dumping repositories ...".blue
|
2013-04-05 12:01:19 -04:00
|
|
|
Backup::Repository.new.dump
|
|
|
|
puts "done".green
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2013-05-05 10:01:10 -04:00
|
|
|
task restore: :environment do
|
2013-04-05 12:01:19 -04:00
|
|
|
puts "Restoring repositories ...".blue
|
|
|
|
Backup::Repository.new.restore
|
|
|
|
puts "done".green
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
namespace :db do
|
2013-05-05 10:01:10 -04:00
|
|
|
task create: :environment do
|
2013-04-05 08:55:02 -04:00
|
|
|
puts "Dumping database ... ".blue
|
2013-04-05 12:01:19 -04:00
|
|
|
Backup::Database.new.dump
|
2013-04-05 08:55:02 -04:00
|
|
|
puts "done".green
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2013-05-05 10:01:10 -04:00
|
|
|
task restore: :environment do
|
2013-04-05 08:55:02 -04:00
|
|
|
puts "Restoring database ... ".blue
|
2013-04-05 12:01:19 -04:00
|
|
|
Backup::Database.new.restore
|
2013-04-05 08:55:02 -04:00
|
|
|
puts "done".green
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
end
|
2013-04-10 08:41:47 -04:00
|
|
|
|
|
|
|
namespace :uploads do
|
2013-05-05 10:01:10 -04:00
|
|
|
task create: :environment do
|
2013-04-10 08:41:47 -04:00
|
|
|
puts "Dumping uploads ... ".blue
|
|
|
|
Backup::Uploads.new.dump
|
|
|
|
puts "done".green
|
|
|
|
end
|
|
|
|
|
2013-05-05 10:01:10 -04:00
|
|
|
task restore: :environment do
|
2013-04-10 08:41:47 -04:00
|
|
|
puts "Restoring uploads ... ".blue
|
|
|
|
Backup::Uploads.new.restore
|
|
|
|
puts "done".green
|
|
|
|
end
|
|
|
|
end
|
2012-12-20 14:17:09 -05:00
|
|
|
end # namespace end: backup
|
2012-07-09 17:45:43 -04:00
|
|
|
end # namespace end: gitlab
|