Esempio n. 1
0
def backup_quoted_rpaths(rpout):
	"""Get QuotedRPath versions of important RPaths.  Return rpout"""
	global incdir
	SetConnections.UpdateGlobal(
		'rbdir', FilenameMapping.get_quotedrpath(Globals.rbdir))
	incdir = FilenameMapping.get_quotedrpath(incdir)
	return FilenameMapping.get_quotedrpath(rpout)
Esempio n. 2
0
def backup_set_globals(rpin, force):
	"""Given rps for source filesystem and repository, set fsa globals

	This should be run on the destination connection, because we may
	need to write a new chars_to_quote file.

	"""
	assert Globals.rbdir.conn is Globals.local_connection
	src_fsa = rpin.conn.fs_abilities.get_readonly_fsa('source', rpin)
	log.Log(str(src_fsa), 4)
	dest_fsa = FSAbilities('destination').init_readwrite(Globals.rbdir)
	log.Log(str(dest_fsa), 4)

	bsg = BackupSetGlobals(rpin.conn, Globals.rbdir.conn, src_fsa, dest_fsa)
	bsg.set_eas()
	bsg.set_acls()
	bsg.set_win_acls()
	bsg.set_unicode_filenames()
	bsg.set_resource_forks()
	bsg.set_carbonfile()
	bsg.set_hardlinks()
	bsg.set_fsync_directories()
	bsg.set_change_ownership()
	bsg.set_high_perms()
	bsg.set_symlink_perms()
	update_quoting = bsg.set_chars_to_quote(Globals.rbdir, force)
	bsg.set_special_escapes(Globals.rbdir)
	bsg.set_compatible_timestamps()

	if update_quoting and force:
		FilenameMapping.update_quoting(Globals.rbdir)
Esempio n. 3
0
def backup_quoted_rpaths(rpout):
	"""Get QuotedRPath versions of important RPaths.  Return rpout"""
	global incdir
	SetConnections.UpdateGlobal(
		'rbdir', FilenameMapping.get_quotedrpath(Globals.rbdir))
	incdir = FilenameMapping.get_quotedrpath(incdir)
	return FilenameMapping.get_quotedrpath(rpout)
Esempio n. 4
0
def backup_set_globals(rpin, force):
    """Given rps for source filesystem and repository, set fsa globals

	This should be run on the destination connection, because we may
	need to write a new chars_to_quote file.

	"""
    assert Globals.rbdir.conn is Globals.local_connection
    src_fsa = rpin.conn.fs_abilities.get_readonly_fsa('source', rpin)
    log.Log(str(src_fsa), 4)
    dest_fsa = FSAbilities('destination').init_readwrite(Globals.rbdir)
    log.Log(str(dest_fsa), 4)

    bsg = BackupSetGlobals(rpin.conn, Globals.rbdir.conn, src_fsa, dest_fsa)
    bsg.set_eas()
    bsg.set_acls()
    bsg.set_win_acls()
    bsg.set_unicode_filenames()
    bsg.set_resource_forks()
    bsg.set_carbonfile()
    bsg.set_hardlinks()
    bsg.set_fsync_directories()
    bsg.set_change_ownership()
    bsg.set_high_perms()
    bsg.set_symlink_perms()
    update_quoting = bsg.set_chars_to_quote(Globals.rbdir, force)
    bsg.set_special_escapes(Globals.rbdir)
    bsg.set_compatible_timestamps()

    if update_quoting and force:
        FilenameMapping.update_quoting(Globals.rbdir)
Esempio n. 5
0
def restore_init_quoting(src_rp):
	"""Change rpaths into quoted versions of themselves if necessary"""
	global restore_root
	if not Globals.chars_to_quote: return src_rp
	for conn in Globals.connections: conn.FilenameMapping.set_init_quote_vals()
	restore_root = FilenameMapping.get_quotedrpath(restore_root)
	SetConnections.UpdateGlobal(
		'rbdir', FilenameMapping.get_quotedrpath(Globals.rbdir))
	return FilenameMapping.get_quotedrpath(src_rp)
Esempio n. 6
0
def restore_init_quoting(src_rp):
	"""Change rpaths into quoted versions of themselves if necessary"""
	global restore_root
	if not Globals.chars_to_quote: return src_rp
	for conn in Globals.connections: conn.FilenameMapping.set_init_quote_vals()
	restore_root = FilenameMapping.get_quotedrpath(restore_root)
	SetConnections.UpdateGlobal(
		'rbdir', FilenameMapping.get_quotedrpath(Globals.rbdir))
	return FilenameMapping.get_quotedrpath(src_rp)
Esempio n. 7
0
	def set_chars_to_quote(self, rbdir, force):
		"""Set chars_to_quote setting for backup session

		Unlike most other options, the chars_to_quote setting also
		depends on the current settings in the rdiff-backup-data
		directory, not just the current fs features.

		"""
		(ctq, update) = self.compare_ctq_file(rbdir,
				self.get_ctq_from_fsas(), force)

		SetConnections.UpdateGlobal('chars_to_quote', ctq)
		if Globals.chars_to_quote: FilenameMapping.set_init_quote_vals()
		return update
Esempio n. 8
0
    def set_chars_to_quote(self, rbdir, force):
        """Set chars_to_quote setting for backup session

		Unlike most other options, the chars_to_quote setting also
		depends on the current settings in the rdiff-backup-data
		directory, not just the current fs features.

		"""
        (ctq, update) = self.compare_ctq_file(rbdir, self.get_ctq_from_fsas(),
                                              force)

        SetConnections.UpdateGlobal('chars_to_quote', ctq)
        if Globals.chars_to_quote: FilenameMapping.set_init_quote_vals()
        return update
Esempio n. 9
0
def get_inclist(inc_rpath):
	"""Returns increments with given base"""
	dirname, basename = inc_rpath.dirsplit()
	if Globals.chars_to_quote: basename = FilenameMapping.unquote(basename)
	parent_dir = inc_rpath.__class__(inc_rpath.conn, dirname, ())
	if not parent_dir.isdir(): return [] # inc directory not created yet
	index = inc_rpath.index

	inc_list = []
	for filename in parent_dir.listdir():
		inc_info = rpath.get_incfile_info(filename)
		if inc_info and inc_info[3] == basename:
			inc = parent_dir.append(filename)
			assert inc.isincfile()
			inc_list.append(inc)
	return inc_list
Esempio n. 10
0
def describe_incs_human(incs, mirror_time, mirrorrp):
	"""Return a string describing all the the root increments"""
	incpairs = [(inc.getinctime(), inc) for inc in incs]
	incpairs.sort()

	result = ["Found %d increments:" % len(incpairs)]
	if Globals.chars_to_quote:
		for time, inc in incpairs:
			result.append("    %s   %s" %
						  (FilenameMapping.unquote(inc.dirsplit()[1]),
						   Time.timetopretty(time)))
	else:
		for time, inc in incpairs:
			result.append("    %s   %s" %
						  (inc.dirsplit()[1], Time.timetopretty(time)))
	result.append("Current mirror: %s" % Time.timetopretty(mirror_time))
	return "\n".join(result)
Esempio n. 11
0
def get_inclist(inc_rpath):
    """Returns increments with given base"""
    dirname, basename = inc_rpath.dirsplit()
    if Globals.chars_to_quote:
        basename = FilenameMapping.unquote(basename)
    parent_dir = inc_rpath.__class__(inc_rpath.conn, dirname, ())
    if not parent_dir.isdir():
        return []  # inc directory not created yet
    index = inc_rpath.index

    inc_list = []
    for filename in parent_dir.listdir():
        inc_info = rpath.get_incfile_info(filename)
        if inc_info and inc_info[3] == basename:
            inc = parent_dir.append(filename)
            assert inc.isincfile()
            inc_list.append(inc)
    return inc_list