Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
fixes #19743, #18358 - allows user to bypass subdir creation
Browse files Browse the repository at this point in the history
  • Loading branch information
cfouant committed Jun 1, 2017
1 parent aa1a6e9 commit a9ce577
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions katello/katello-backup
Expand Up @@ -35,6 +35,10 @@ optparse = OptionParser.new do |opts|
@options[:logical_backup] = logical
end

opts.on("--preserve-directory", "Do not create a time-stamped subdirectory") do |no_subdir|
@options[:no_subdir] = no_subdir
end

opts.parse!

if ARGV.length == 0
Expand All @@ -56,7 +60,7 @@ def run_cmd(command, exit_codes=[0])
end

def create_directories(directory)
@dir = File.join directory, "katello-backup-" + DateTime.now.strftime('%Y%m%d%H%M%S')
@dir = File.join directory, "katello-backup-" + DateTime.now.strftime('%Y%m%d%H%M%S') unless @options[:no_subdir]
puts "Creating backup folder #{@dir}"
FileUtils.mkdir_p @dir
FileUtils.chown_R nil, 'postgres', directory
Expand Down Expand Up @@ -169,7 +173,11 @@ else
generate_metadata
puts "Done."

FileUtils.cp Dir.glob("#{@options[:incremental]}/.*.snar"), @dir if @options[:incremental]
if @options[:incremental]
FileUtils.cp Dir.glob(File.join(@options[:incremental], '.*.snar')), @dir
elsif @options[:no_subdir]
FileUtils.rm_rf Dir.glob(File.join(@dir, '.*.snar'))
end

puts "Backing up config files... "
run_cmd("tar --selinux --create --gzip --file=config_files.tar.gz --listed-incremental=.config.snar #{CONFIGS.join(' ')} 2>/dev/null", [0,2])
Expand Down

0 comments on commit a9ce577

Please sign in to comment.