def backup_data(self, backup_resource, manifest_path): LOG.info("Starting Tar engine backup stream") tar_command = tar_builders.TarCommandBuilder(backup_resource, self.compression_algo, self.is_windows) if self.encrypt_pass_file: tar_command.set_encryption(self.encrypt_pass_file) if self.dereference_symlink: tar_command.set_dereference(self.dereference_symlink) tar_command.set_exclude(self.exclude) tar_command.set_listed_incremental(manifest_path) command = tar_command.build() LOG.info("Execution command: \n{}".format(command)) tar_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, executable='/bin/bash') read_pipe = tar_process.stdout tar_chunk = read_pipe.read(self.max_segment_size) while tar_chunk: yield tar_chunk tar_chunk = read_pipe.read(self.max_segment_size) self.check_process_output(tar_process, 'Backup') LOG.info("Tar engine stream completed")
def backup_data(self, backup_path, manifest_path): logging.info("Tar engine backup stream enter") tar_command = tar_builders.TarCommandBuilder(backup_path, self.compression_algo, self.is_windows) if self.encrypt_pass_file: tar_command.set_encryption(self.encrypt_pass_file) if self.dereference_symlink: tar_command.set_dereference(self.dereference_symlink) tar_command.set_exclude(self.exclude) tar_command.set_listed_incremental(manifest_path) command = tar_command.build() logging.info("Execution command: \n{}".format(command)) tar_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) read_pipe = tar_process.stdout tar_chunk = read_pipe.read(self.chunk_size) while tar_chunk: yield tar_chunk tar_chunk = read_pipe.read(self.chunk_size) tar_err = tar_process.communicate()[1] if 'error' in tar_err.lower(): logging.exception('[*] Backup error: {0}'.format(tar_err)) sys.exit(1) if tar_process.returncode: logging.error('[*] Backup return code is not 0') sys.exit(1) logging.info("Tar engine streaming end")
def backup_data(self, backup_path, manifest_path): logging.info("Tar engine backup stream enter") tar_command = tar_builders.TarCommandBuilder(backup_path, self.compression_algo, self.is_windows) if self.encrypt_pass_file: tar_command.set_encryption(self.encrypt_pass_file) if self.dereference_symlink: tar_command.set_dereference(self.dereference_symlink) tar_command.set_exclude(self.exclude) tar_command.set_listed_incremental(manifest_path) command = tar_command.build() logging.info("Execution command: \n{}".format(command)) tar_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) read_pipe = tar_process.stdout tar_chunk = read_pipe.read(self.chunk_size) while tar_chunk: yield tar_chunk tar_chunk = read_pipe.read(self.chunk_size) self.check_process_output(tar_process, 'Backup') logging.info("Tar engine streaming end")
def test_build_every_arg_windows(self): self.builder = tar_builders.TarCommandBuilder(".", "gzip", True, "gnutar") self.builder.set_listed_incremental("listed-file.tar") self.builder.set_encryption("encrypt_pass_file", "openssl") self.builder.set_dereference("hard") self.builder.set_exclude("excluded_files") self.assertEqual( self.builder.build(), 'gnutar -c -z --incremental --unlink-first --ignore-zeros ' '--hard-dereference --listed-incremental=listed-file.tar ' '--exclude="excluded_files" . ' '| openssl enc -aes-256-cfb -pass file:encrypt_pass_file ' '&& exit ${PIPESTATUS[0]}')
def setUp(self): self.builder = tar_builders.TarCommandBuilder(".", "gzip", False, "gnutar")