gitlab-org--gitlab-foss/lib/tasks/gitlab/backup.rake

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

137 lines
3.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'active_record/fixtures'
namespace :gitlab do
namespace :backup do
2012-09-26 07:18:10 -04:00
# Create backup of GitLab system
desc 'GitLab | Backup | Create a backup of the GitLab system'
task create: :gitlab_environment do
2012-12-23 15:15:25 -05:00
warn_user_is_not_gitlab
Backup::Manager.new(progress).create
end
2012-09-26 07:18:10 -04:00
# Restore backup of GitLab system
desc 'GitLab | Backup | Restore a previously created backup'
task restore: :gitlab_environment do
2012-12-23 15:15:25 -05:00
warn_user_is_not_gitlab
Backup::Manager.new(progress).restore
end
namespace :repo do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('repositories')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('repositories')
end
end
namespace :db do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('db')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('db')
end
end
2013-04-10 08:41:47 -04:00
namespace :builds do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('builds')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('builds')
end
end
2013-04-10 08:41:47 -04:00
namespace :uploads do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('uploads')
2013-04-10 08:41:47 -04:00
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('uploads')
end
end
namespace :artifacts do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('artifacts')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('artifacts')
end
end
namespace :pages do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('pages')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('pages')
end
end
2015-11-18 05:39:26 -05:00
namespace :lfs do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('lfs')
2015-11-18 05:39:26 -05:00
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('lfs')
2015-11-18 05:39:26 -05:00
end
end
namespace :terraform_state do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('terraform_state')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('terraform_state')
end
end
2016-05-16 18:17:57 -04:00
namespace :registry do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('registry')
2016-05-16 18:17:57 -04:00
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('registry')
2016-05-16 18:17:57 -04:00
end
end
namespace :packages do
task create: :gitlab_environment do
Backup::Manager.new(progress).run_create_task('packages')
end
task restore: :gitlab_environment do
Backup::Manager.new(progress).run_restore_task('packages')
end
end
def progress
if ENV['CRON']
2014-11-20 09:54:39 -05:00
# We need an object we can say 'puts' and 'print' to; let's use a
# StringIO.
require 'stringio'
StringIO.new
else
$stdout
2013-04-10 08:41:47 -04:00
end
end
end
# namespace end: backup
end
# namespace end: gitlab