Skip to content
代码片段 群组 项目
提交 f7356fa0 编辑于 作者: Gabriel Mazetto's avatar Gabriel Mazetto
浏览文件

Introduce Backup related subcommands

上级 d311427b
No related branches found
No related tags found
1 合并请求!2419Fix TanukiBot spec relying on outdated code
......@@ -7,12 +7,13 @@ module Gitlab
module Backup
# GitLab Backup CLI
module Cli
autoload :VERSION, 'gitlab/backup/cli/version'
autoload :Commands, 'gitlab/backup/cli/commands'
autoload :Dependencies, 'gitlab/backup/cli/dependencies'
autoload :Output, 'gitlab/backup/cli/output'
autoload :Runner, 'gitlab/backup/cli/runner'
autoload :Utils, 'gitlab/backup/cli/utils'
autoload :Dependencies, 'gitlab/backup/cli/dependencies'
autoload :Shell, 'gitlab/backup/cli/shell'
autoload :Utils, 'gitlab/backup/cli/utils'
autoload :VERSION, 'gitlab/backup/cli/version'
Error = Class.new(StandardError)
......
......@@ -4,6 +4,7 @@ module Gitlab
module Backup
module Cli
module Commands
autoload :BackupSubcommand, 'gitlab/backup/cli/commands/backup_subcommand'
autoload :Command, 'gitlab/backup/cli/commands/command'
end
end
......
# frozen_string_literal: true
module Gitlab
module Backup
module Cli
module Commands
class BackupSubcommand < Command
package_name 'Backup'
desc 'all', 'Creates a backup including repositories, database and local files'
def all
duration = measure_duration do
Gitlab::Backup::Cli::Output.info("Initializing environment...")
Gitlab::Backup::Cli.rails_environment!
end
Gitlab::Backup::Cli::Output.info("Environment loaded. (#{duration.in_seconds}s)")
duration = measure_duration do
Gitlab::Backup::Cli::Output.info("Starting GitLab backup...")
# TODO: perform backup here...
sleep(1)
end
Gitlab::Backup::Cli::Output.info("Backup finished. (#{duration.in_seconds}s)")
end
private
def measure_duration
start = Time.now
yield
ActiveSupport::Duration.build(Time.now - start)
end
end
end
end
end
end
......@@ -17,6 +17,9 @@ class Runner < Commands::Command
def version
puts "GitLab Backup CLI (#{VERSION})" # rubocop:disable Rails/Output -- CLI output
end
desc 'backup', 'Manage repositories, database and files backup creation'
subcommand 'backup', Commands::BackupSubcommand
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册