Creates and downloads the backup of UCS.
		
		- type specifies the type of backup i.e. fullstate/config-logical/config-system/config-all.
		- pathPattern specifies the path of the Backup file. 
		- timeoutSec specifies the time in seconds for which method waits for the backUp file to generate else exit.

def BackupUcs(self, type, pathPattern, timeoutSec=600, preservePooledValues=False, dumpXml=None):
		"""
		Creates and downloads the backup of UCS.
		
		- type specifies the type of backup i.e. fullstate/config-logical/config-system/config-all.
		- pathPattern specifies the path of the Backup file. 
		- timeoutSec specifies the time in seconds for which method waits for the backUp file to generate else exit.
		"""
		from UcsBase import WriteUcsWarning, UcsUtils, ManagedObject, WriteObject, UcsUtils, UcsValidationException, \
			UcsException
		from Mos import TopSystem, MgmtBackup
		from Ucs import ConfigConfig
		import os, platform

		if (self._transactionInProgress):
			raise UcsValidationException(
				"UCS transaction in progress. Cannot execute BackupUcs. Complete or Undo UCS transaction.")
		# raise Exception("UCS transaction in progress. Cannot execute BackupUcs. Complete or Undo UCS transaction.")
		if (type == None or pathPattern == None):
			raise UcsValidationException("type or pathPattern parameter is not provided.")
		# raise Exception("Please provide type/pathPattern parameter.")
		if type == "fullstate" and not pathPattern.endswith('.tar.gz'):
			raise UcsValidationException('pathPattern should end with .tar.gz')
		elif not pathPattern.endswith('.xml'):
			raise UcsValidationException('pathPattern should end with .xml')

		directory = os.path.dirname(pathPattern)
		if not (os.path.exists(directory)):
			os.makedirs(directory)
		hostname = platform.node().lower() + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
		mgmtBackup = ManagedObject(NamingId.MGMT_BACKUP)
		mgmtBackup.Hostname = hostname
		dn = UcsUtils.MakeDn([ManagedObject(NamingId.TOP_SYSTEM).MakeRn(), mgmtBackup.MakeRn()])

		if (type == MgmtBackup.CONST_TYPE_FULL_STATE or type == MgmtBackup.CONST_TYPE_CONFIG_SYSTEM):
			preservePooledValues = False

		mgmtBackup = ManagedObject(NamingId.MGMT_BACKUP)
		mgmtBackup.AdminState = MgmtBackup.CONST_ADMIN_STATE_ENABLED
		mgmtBackup.Dn = dn
		mgmtBackup.Status = Status.CREATED
		mgmtBackup.Proto = MgmtBackup.CONST_PROTO_HTTP
		mgmtBackup.Type = type
		mgmtBackup.RemoteFile = pathPattern

		if (preservePooledValues):
			mgmtBackup.PreservePooledValues = MgmtBackup.CONST_PRESERVE_POOLED_VALUES_YES
		else:
			mgmtBackup.PreservePooledValues = MgmtBackup.CONST_PRESERVE_POOLED_VALUES_NO

		inConfig = ConfigConfig()
		inConfig.AddChild(mgmtBackup)
		ccm = self.ConfigConfMo(dn=dn, inConfig=inConfig, inHierarchical=YesOrNo.FALSE, dumpXml=dumpXml)
		if (ccm.errorCode != 0):
			raise UcsException(ccm.errorCode, ccm.errorDescr)
		# raise Exception('[Error]: BackupUcs [Code]:' + ccm.errorCode + ' [Description]:' + ccm.errorDescr)

		duration = timeoutSec
		poll_interval = 2

		# Checking for the backup to compete.
		adminStateTemp = None
		crDn = None
		while (True):
			crDn = self.ConfigResolveDn(dn, inHierarchical=YesOrNo.FALSE, dumpXml=dumpXml)
			if (crDn.errorCode == 0):
				for eachMgmtDn in crDn.OutConfig.GetChild():
					adminStateTemp = eachMgmtDn.AdminState
			else:
				raise UcsException(crDn.errorCode, crDn.errorDescr)
			# raise Exception('[Error]: BackupUcs [Code]:' + crDn.errorCode + ' [Description]:' + crDn.errorDescr)

			# Break condition:- if state id disabled then break
			if (adminStateTemp == MgmtBackup.CONST_ADMIN_STATE_DISABLED):
				break

			time.sleep(min(duration, poll_interval))
			duration = max(0, (duration - poll_interval))

			if duration == 0:
				mgmtBackup = ManagedObject(NamingId.MGMT_BACKUP)
				mgmtBackup.Dn = dn
				mgmtBackup.Status = Status.DELETED
				inConfig.AddChild(mgmtBackup)
				ccm = self.ConfigConfMo(dn=dn, inConfig=inConfig, inHierarchical=YesOrNo.FALSE, dumpXml=dumpXml)
				if (ccm.errorCode != 0):
					raise UcsException(ccm.errorCode, ccm.errorDescr)
				# raise Exception('[Error]: BackupUcs [Code]:' + ccm.errorCode + ' [Description]:' + ccm.errorDescr)
				raise UcsValidationException('BackupUcs timed out')
				# raise Exception('BackupUcs timed out')

		WriteObject(crDn.OutConfig.GetChild())  # BackUp Complete.

		fileSource = "backupfile/" + os.path.basename(pathPattern)

		try:
			UcsUtils.DownloadFile(self, fileSource, pathPattern)
		except Exception, err:
			WriteUcsWarning(str(err))

		inConfig = ConfigConfig()
		mgmtBackup = ManagedObject(NamingId.MGMT_BACKUP)
		mgmtBackup.Dn = dn
		mgmtBackup.Status = Status.DELETED
		inConfig.AddChild(mgmtBackup)
		ccm = self.ConfigConfMo(dn=dn, inConfig=inConfig, inHierarchical=YesOrNo.FALSE, dumpXml=dumpXml)
		if (ccm.errorCode != 0):
			raise UcsException(ccm.errorCode, ccm.errorDescr)
		# raise Exception('[Error]: BackupUcs [Code]:' + ccm.errorCode + ' [Description]:' + ccm.errorDescr)

		return crDn.OutConfig.GetChild()