def connect(self): conn_value = super().connect() if conn_value: Security.initialize(self.get_security_class(), [], security_level=self.values.restrict_mode, restrict_path=self.values.restrict_path) return conn_value
def connect(self): """ Connect to potentially provided locations arguments, remote or local. Defines the current time as being the time of a potentially upcoming backup. Returns self, to be used as context manager. """ if 'locations' in self.values: # TODO encapsulate the following lines into one # connections/connections_mgr construct, so that the action doesn't # need to care about cmdpairs and Security (which would become a # feature of the connection). cmdpairs = SetConnections.get_cmd_pairs( self.values.locations, remote_schema=self.remote_schema, ssh_compression=self.values.ssh_compression, remote_tempdir=self.remote_tempdir, term_verbosity=log.Log.term_verbosity) Security.initialize(self.get_security_class(), cmdpairs) self.connected_locations = list( map(SetConnections.get_connected_rpath, cmdpairs)) else: Security.initialize(self.get_security_class(), []) self.connected_locations = [] # once the connection is set, we can define "now" as being the current # time, unless the user defined a fixed a current time. Time.set_current_time(self.values.current_time) return self
def InternalBackup(source_local, dest_local, src_dir, dest_dir, current_time = None, eas = None, acls = None): """Backup src to dest internally This is like rdiff_backup but instead of running a separate rdiff-backup script, use the separate *.py files. This way the script doesn't have to be rebuild constantly, and stacktraces have correct line/file references. """ Globals.current_time = current_time #_reset_connections() Globals.security_level = "override" remote_schema = '%s' if not source_local: src_dir = "cd test1; python ../server.py ../%s::../%s" % \ (SourceDir, src_dir) if not dest_local: dest_dir = "cd test2/tmp; python ../../server.py ../../%s::../../%s" \ % (SourceDir, dest_dir) cmdpairs = SetConnections.get_cmd_pairs([src_dir, dest_dir], remote_schema) Security.initialize("backup", cmdpairs) rpin, rpout = map(SetConnections.cmdpair2rp, cmdpairs) for attr in ('eas_active', 'eas_write', 'eas_conn'): SetConnections.UpdateGlobal(attr, eas) for attr in ('acls_active', 'acls_write', 'acls_conn'): SetConnections.UpdateGlobal(attr, acls) Main.misc_setup([rpin, rpout]) Main.Backup(rpin, rpout) Main.cleanup()
def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time, eas=None, acls=None): """Restore mirror_dir to dest_dir at given time This will automatically find the increments.XXX.dir representing the time specified. The mirror_dir and dest_dir are relative to the testing directory and will be modified for remote trials. """ Main._force = 1 Main._restore_root_set = 0 Globals.security_level = "override" cmdpairs = _internal_get_cmd_pairs(mirror_local, dest_local, mirror_dir, dest_dir) Security.initialize("restore", cmdpairs) mirror_rp, dest_rp = list(map(SetConnections.cmdpair2rp, cmdpairs)) for attr in ('eas_active', 'eas_write', 'eas_conn'): SetConnections.UpdateGlobal(attr, eas) for attr in ('acls_active', 'acls_write', 'acls_conn'): SetConnections.UpdateGlobal(attr, acls) Main._misc_setup([mirror_rp, dest_rp]) inc = get_increment_rp(mirror_rp, time) if inc: Main._action_restore(get_increment_rp(mirror_rp, time), dest_rp) else: # use alternate syntax Main._restore_timestr = str(time) Main._action_restore(mirror_rp, dest_rp, restore_as_of=1) Main._cleanup()
def InternalBackup(source_local, dest_local, src_dir, dest_dir, current_time=None, eas=None, acls=None): """Backup src to dest internally This is like rdiff_backup but instead of running a separate rdiff-backup script, use the separate *.py files. This way the script doesn't have to be rebuild constantly, and stacktraces have correct line/file references. """ Globals.current_time = current_time Globals.security_level = "override" cmdpairs = _internal_get_cmd_pairs(source_local, dest_local, src_dir, dest_dir) Security.initialize("backup", cmdpairs) rpin, rpout = list(map(SetConnections.cmdpair2rp, cmdpairs)) for attr in ('eas_active', 'eas_write', 'eas_conn'): SetConnections.UpdateGlobal(attr, eas) for attr in ('acls_active', 'acls_write', 'acls_conn'): SetConnections.UpdateGlobal(attr, acls) Main._misc_setup([rpin, rpout]) Main._action_backup(rpin, rpout) Main._cleanup()
def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time, eas=None, acls=None): """Restore mirror_dir to dest_dir at given time This will automatically find the increments.XXX.dir representing the time specified. The mirror_dir and dest_dir are relative to the testing directory and will be modified for remote trials. """ Main.force = 1 Main.restore_root_set = 0 remote_schema = b'%s' Globals.security_level = "override" if not mirror_local: mirror_dir = b"cd %s; %s/server.py::%s" % (abs_remote1_dir, abs_testing_dir, mirror_dir) if not dest_local: dest_dir = b"cd %s; %s/server.py::%s" % (abs_remote2_dir, abs_testing_dir, dest_dir) cmdpairs = SetConnections.get_cmd_pairs([mirror_dir, dest_dir], remote_schema) Security.initialize("restore", cmdpairs) mirror_rp, dest_rp = list(map(SetConnections.cmdpair2rp, cmdpairs)) for attr in ('eas_active', 'eas_write', 'eas_conn'): SetConnections.UpdateGlobal(attr, eas) for attr in ('acls_active', 'acls_write', 'acls_conn'): SetConnections.UpdateGlobal(attr, acls) Main.misc_setup([mirror_rp, dest_rp]) inc = get_increment_rp(mirror_rp, time) if inc: Main.Restore(get_increment_rp(mirror_rp, time), dest_rp) else: # use alternate syntax Main.restore_timestr = str(time) Main.Restore(mirror_rp, dest_rp, restore_as_of=1) Main.cleanup()
def connect(self): """ Connect to potentially provided locations arguments, remote or local. Returns self, to be used as context manager. """ if 'locations' in self.values: # TODO encapsulate the following lines into one # connections/connections_mgr construct, so that the action doesn't # need to care about cmdpairs and Security (which would become a # feature of the connection). cmdpairs = SetConnections.get_cmd_pairs( self.values.locations, remote_schema=self.remote_schema, ssh_compression=self.values.ssh_compression) Security.initialize(self.get_security_class(), cmdpairs) self.connected_locations = list( map(SetConnections.get_connected_rpath, cmdpairs)) else: self.connected_locations = [] return self
def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time, eas = None, acls = None): """Restore mirror_dir to dest_dir at given time This will automatically find the increments.XXX.dir representing the time specified. The mirror_dir and dest_dir are relative to the testing directory and will be modified for remote trials. """ Main.force = 1 Main.restore_root_set = 0 remote_schema = '%s' Globals.security_level = "override" #_reset_connections() if not mirror_local: mirror_dir = "cd test1; python ../server.py ../%s::../%s" % \ (SourceDir, mirror_dir) if not dest_local: dest_dir = "cd test2/tmp; python ../../server.py ../../%s::../../%s" \ % (SourceDir, dest_dir) cmdpairs = SetConnections.get_cmd_pairs([mirror_dir, dest_dir], remote_schema) Security.initialize("restore", cmdpairs) mirror_rp, dest_rp = map(SetConnections.cmdpair2rp, cmdpairs) for attr in ('eas_active', 'eas_write', 'eas_conn'): SetConnections.UpdateGlobal(attr, eas) for attr in ('acls_active', 'acls_write', 'acls_conn'): SetConnections.UpdateGlobal(attr, acls) Main.misc_setup([mirror_rp, dest_rp]) inc = get_increment_rp(mirror_rp, time) if inc: Main.Restore(get_increment_rp(mirror_rp, time), dest_rp) else: # use alternate syntax Main.restore_timestr = str(time) Main.Restore(mirror_rp, dest_rp, restore_as_of = 1) Main.cleanup()