Class: UBSafe::Commands::SVNBackup

Inherits:
Backup
  • Object
show all
Defined in:
lib/ubsafe/ubsafe_commands/ubsafe_command_backup_svn.rb

Instance Method Summary collapse

Methods inherited from Backup

#after_copy_backup, #after_rotate_destination_files, #after_source_backup, #all_backup_names, #backup, #before_clean_source, #before_copy_backup, #before_rotate_destination_files, #clean_source, #copy_backup, #create_and_copy_backup, #create_source_backup, #email_notify, #get_backup_file_name, #get_backup_file_name_with_generation, #get_remote_modified_timestamp, #initialize, instance, #remote_file_exists?, #rotate_destination_files, #rotate_destination_files_unconditionally, #scp_cmd, #ssh_cmd

Constructor Details

This class inherits a constructor from UBSafe::Commands::Backup

Instance Method Details

#after_clean_sourceSymbol

Hook to allow customization after cleaning source

Returns:

  • (Symbol)

    :success or :failure



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ubsafe/ubsafe_commands/ubsafe_command_backup_svn.rb', line 38

def after_clean_source
  tmp_dir = File.expand_path(@backup_options[:temporary_directory])
  svn_tmp_dir = File.join(tmp_dir,'svn')
  cmd_output = `rm -rf #{svn_tmp_dir}`
  cmd_status = $?
  cmd_status == 0 ? :success : :failure
  if cmd_status == :failure
    @log.error("Backup #{@backup_name} after_clean_source failed. Output #{cmd_output}")
  end
  return cmd_status
end

#before_source_backupSymbol

Hook to allow customization before creating source backup

Returns:

  • (Symbol)

    :success or :failure



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ubsafe/ubsafe_commands/ubsafe_command_backup_svn.rb', line 14

def before_source_backup
  source_tree = File.expand_path(@backup_options[:source_tree])
  tmp_dir = File.expand_path(@backup_options[:temporary_directory])
  svn_tmp_dir = File.join(tmp_dir,'svn')
  FileUtils.mkdir_p(svn_tmp_dir)
  cmd = "svnadmin hotcopy #{source_tree} #{svn_tmp_dir}"
  cmd_output = `#{cmd}`
  cmd_status = $?
  cmd_status = cmd_status == 0 ? :success : :failure
  if cmd_status == :failure
    # cleanup
    cmd_output = `rm -rf #{svn_tmp_dir}`
    @log.error("Backup #{@backup_name} before_source_backup failed during hotcopy. Output #{cmd_output}")
  end
  # Point source to hotcopy so rest of the world works
  @backup_options[:source_tree] = svn_tmp_dir
  return cmd_status
end