import os
import shutil
import logging

logger = logging.getLogger("thefactz.sysadmin.backup")

class BackupItemBase:
	"""
	Base class for backup item classes which perform backup activities for a single archive of items of a particular type (e.g. filesystem, dbs, etc).
	"""
	
	def doBackup(self):
		"""
		Performs backup for this backup item.
		In base class performs no function and **must** be overridden in derived classes
		"""
		pass
	
	def runCommand(self, command):
		"""
		Run a shell command (UNIX or windows)
		
		@return the resulting error code
		"""
		# [[TODO: use pipes and get back stderr etc ...]]
		err_code = os.system(command)
		if(err_code != 0):
			logger.error("Shell command failed: " + command)
		return err_code

