debian-mirror-gitlab/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

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
require 'active_record/fixtures'
namespace :gitlab do
namespace :backup do
# Create backup of GitLab system
2020-03-13 15:44:24 +05:30
desc 'GitLab | Backup | Create a backup of the GitLab system'
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2014-09-02 18:07:02 +05:30
warn_user_is_not_gitlab
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).create
2014-09-02 18:07:02 +05:30
end
# Restore backup of GitLab system
2020-03-13 15:44:24 +05:30
desc 'GitLab | Backup | Restore a previously created backup'
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2014-09-02 18:07:02 +05:30
warn_user_is_not_gitlab
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).restore
2014-09-02 18:07:02 +05:30
end
namespace :repo do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('repositories')
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('repositories')
2014-09-02 18:07:02 +05:30
end
end
namespace :db do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('db')
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('db')
2014-09-02 18:07:02 +05:30
end
end
2015-09-25 12:07:36 +05:30
namespace :builds do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('builds')
2015-09-25 12:07:36 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('builds')
2015-09-25 12:07:36 +05:30
end
end
2014-09-02 18:07:02 +05:30
namespace :uploads do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('uploads')
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('uploads')
2015-04-26 12:48:37 +05:30
end
end
2015-11-26 14:37:03 +05:30
namespace :artifacts do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('artifacts')
2015-11-26 14:37:03 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('artifacts')
2015-11-26 14:37:03 +05:30
end
end
2017-08-17 22:00:37 +05:30
namespace :pages do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('pages')
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('pages')
2017-08-17 22:00:37 +05:30
end
end
2015-11-26 14:37:03 +05:30
namespace :lfs do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('lfs')
2015-11-26 14:37:03 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('lfs')
2015-11-26 14:37:03 +05:30
end
end
2022-03-02 08:16:31 +05:30
namespace :terraform_state do
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('terraform_state')
2022-03-02 08:16:31 +05:30
end
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('terraform_state')
2022-03-02 08:16:31 +05:30
end
end
2016-06-02 11:05:42 +05:30
namespace :registry do
2018-03-17 18:26:18 +05:30
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('registry')
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('registry')
2016-06-02 11:05:42 +05:30
end
end
2022-03-02 08:16:31 +05:30
namespace :packages do
task create: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_create_task('packages')
2022-03-02 08:16:31 +05:30
end
task restore: :gitlab_environment do
2022-04-04 11:22:00 +05:30
Backup::Manager.new(progress).run_restore_task('packages')
2022-03-02 08:16:31 +05:30
end
end
2018-11-08 19:23:39 +05:30
def progress
2015-04-26 12:48:37 +05:30
if ENV['CRON']
# We need an object we can say 'puts' and 'print' to; let's use a
# StringIO.
require 'stringio'
2018-11-08 19:23:39 +05:30
StringIO.new
2015-04-26 12:48:37 +05:30
else
2018-11-08 19:23:39 +05:30
$stdout
2014-09-02 18:07:02 +05:30
end
end
2020-11-24 15:15:51 +05:30
end
# namespace end: backup
end
# namespace end: gitlab