def setup(self): # in setup we return as soon as we detect an issue to avoid changing # too much return_code = super().setup() if return_code != 0: return return_code return_code = self._set_no_compression_regexp() if return_code != 0: return return_code return_code = self.dir.setup() if return_code != 0: return return_code owners_map = { "users_map": self.values.user_mapping_file, "groups_map": self.values.group_mapping_file, "preserve_num_ids": self.values.preserve_numerical_ids } return_code = self.repo.setup(self.dir, owners_map=owners_map) if return_code != 0: return return_code # TODO validate how much of the following lines and methods # should go into the directory/repository modules if Globals.get_api_version() < 201: # compat200 SetConnections.BackupInitConnections(self.dir.base_dir.conn, self.repo.base_dir.conn) self.repo.base_dir.conn.fs_abilities.backup_set_globals( self.dir.base_dir, self.values.force) self.repo.setup_quoting() previous_time = self.repo.get_mirror_time() if previous_time >= Time.getcurtime(): log.Log("The last backup is not in the past. Aborting.", log.ERROR) return 1 if log.Log.verbosity > 0: try: # the target repository must be writable log.Log.open_logfile(self.repo.data_dir.append("backup.log")) except (log.LoggerError, Security.Violation) as exc: log.Log("Unable to open logfile due to '{ex}'".format(ex=exc), log.ERROR) return 1 log.ErrorLog.open(Time.getcurtimestr(), compress=self.values.compression) (select_opts, select_data) = selection.get_prepared_selections( self.values.selections) self.dir.set_select(select_opts, select_data) self._warn_if_infinite_recursion(self.dir.base_dir, self.repo.base_dir) return 0
def setPathnames(self, src_path, src_return, dest_path, dest_return): """Start servers which will run in src_path and dest_path respectively If either is None, then no server will be run and local process will handle that end. src_return and dest_return are the prefix back to the original rdiff-backup directory. So for instance is src_path is "test2/tmp", then src_return will be '../'. """ # Clear old data that may rely on deleted connections Globals.isbackup_writer = None Globals.isbackup_reader = None Globals.rbdir = None print "Setting up connection" self.src_prefix, self.src_conn = \ self.get_prefix_and_conn(src_path, src_return) self.dest_prefix, self.dest_conn = \ self.get_prefix_and_conn(dest_path, dest_return) SetConnections.BackupInitConnections(self.src_conn, self.dest_conn) Globals.restrict_path = "/" # we aren't testing security here assert not os.system("rm -rf testfiles/output* " "testfiles/restoretarget* " "testfiles/noperms_output testfiles/root_output " "testfiles/unreadable_out") self.inc1rp = self.get_src_rp("testfiles/increment1") self.inc2rp = self.get_src_rp('testfiles/increment2') self.inc3rp = self.get_src_rp('testfiles/increment3') self.inc4rp = self.get_src_rp('testfiles/increment4') self.rpout_inc = self.get_dest_rp('testfiles/output_inc') self.rpout1 = self.get_dest_rp('testfiles/restoretarget1') self.rpout2 = self.get_dest_rp('testfiles/restoretarget2') self.rpout3 = self.get_dest_rp('testfiles/restoretarget3') self.rpout4 = self.get_dest_rp('testfiles/restoretarget4') self.rpout = self.get_dest_rp('testfiles/output') self.set_rbdir(self.rpout) self.noperms = self.get_src_rp('testfiles/noperms') self.noperms_out = self.get_dest_rp('testfiles/noperms_output') self.rootfiles = self.get_src_rp('testfiles/root') self.rootfiles_out = self.get_dest_rp('testfiles/root_output') self.rootfiles2 = self.get_src_rp('testfiles/root2') self.rootfiles21 = self.get_src_rp('testfiles/root2.1') self.rootfiles_out2 = self.get_dest_rp('testfiles/root_output2') self.one_unreadable = self.get_src_rp('testfiles/one_unreadable') self.one_unreadable_out = self.get_dest_rp('testfiles/unreadable_out')
def setup(self): # in setup we return as soon as we detect an issue to avoid changing # too much return_code = super().setup() if return_code != 0: return return_code return_code = self.source.setup() if return_code != 0: return return_code return_code = self.target.setup() if return_code != 0: return return_code # TODO validate how much of the following lines and methods # should go into the directory/repository modules SetConnections.BackupInitConnections(self.source.base_dir.conn, self.target.base_dir.conn) self.target.base_dir.conn.fs_abilities.backup_set_globals( self.source.base_dir, self.values.force) self.target.init_quoting(self.values.chars_to_quote) self._init_user_group_mapping(self.target.base_dir.conn) previous_time = self.target.get_mirror_time() if previous_time >= Time.curtime: self.log("The last backup is not in the past. Aborting.", self.log.ERROR) return 1 if self.log.verbosity > 0: try: # the target repository must be writable self.log.open_logfile( self.target.data_dir.append("backup.log")) except (log.LoggerError, Security.Violation) as exc: self.log( "Unable to open logfile due to '{exc}'".format(exc=exc), self.log.ERROR) return 1 # TODO could we get rid of the error log? self.errlog.open(Time.curtimestr, compress=self.values.compression) (select_opts, select_data) = selection.get_prepared_selections( self.values.selections) self.source.set_select(select_opts, select_data) self._warn_if_infinite_recursion(self.source.base_dir, self.target.base_dir) return 0