2021-02-05 07:09:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2020-01-23 01:08:32 -05:00
|
|
|
desc 'GitLab | Backup | Create a backup of the GitLab system'
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2012-12-23 15:15:25 -05:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).create
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2012-09-26 07:18:10 -04:00
|
|
|
# Restore backup of GitLab system
|
2020-01-23 01:08:32 -05:00
|
|
|
desc 'GitLab | Backup | Restore a previously created backup'
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2012-12-23 15:15:25 -05:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).restore
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
namespace :repo do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('repositories')
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('repositories')
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-20 14:17:09 -05:00
|
|
|
namespace :db do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('db')
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('db')
|
2012-07-09 17:45:43 -04:00
|
|
|
end
|
|
|
|
end
|
2013-04-10 08:41:47 -04:00
|
|
|
|
2015-09-15 04:24:30 -04:00
|
|
|
namespace :builds do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('builds')
|
2015-09-15 04:24:30 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('builds')
|
2015-09-15 04:24:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-10 08:41:47 -04:00
|
|
|
namespace :uploads do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('uploads')
|
2013-04-10 08:41:47 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('uploads')
|
2014-11-20 09:46:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-12 17:47:32 -04:00
|
|
|
namespace :artifacts do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('artifacts')
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('artifacts')
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-03 15:28:07 -05:00
|
|
|
namespace :pages do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('pages')
|
2015-11-03 15:28:07 -05:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('pages')
|
2015-11-03 15:28:07 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-18 05:39:26 -05:00
|
|
|
namespace :lfs do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('lfs')
|
2015-11-18 05:39:26 -05:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('lfs')
|
2015-11-18 05:39:26 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-21 22:15:20 -05:00
|
|
|
namespace :terraform_state do
|
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('terraform_state')
|
2021-12-21 22:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('terraform_state')
|
2021-12-21 22:15:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-16 18:17:57 -04:00
|
|
|
namespace :registry do
|
2018-01-24 03:12:33 -05:00
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('registry')
|
2016-05-16 18:17:57 -04:00
|
|
|
end
|
|
|
|
|
2018-01-24 03:12:33 -05:00
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('registry')
|
2016-05-16 18:17:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-11 10:15:55 -05:00
|
|
|
namespace :packages do
|
|
|
|
task create: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_create_task('packages')
|
2022-01-11 10:15:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task restore: :gitlab_environment do
|
2022-02-15 22:18:24 -05:00
|
|
|
Backup::Manager.new(progress).run_restore_task('packages')
|
2022-01-11 10:15:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-24 10:58:25 -04:00
|
|
|
def progress
|
2014-11-20 09:46:04 -05:00
|
|
|
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.
|
2014-11-20 09:46:04 -05:00
|
|
|
require 'stringio'
|
2018-05-24 10:58:25 -04:00
|
|
|
StringIO.new
|
2014-11-20 09:46:04 -05:00
|
|
|
else
|
2018-05-24 10:58:25 -04:00
|
|
|
$stdout
|
2013-04-10 08:41:47 -04:00
|
|
|
end
|
|
|
|
end
|
2020-09-02 14:10:40 -04:00
|
|
|
end
|
|
|
|
# namespace end: backup
|
|
|
|
end
|
|
|
|
# namespace end: gitlab
|