def backup_files(self, environments=pantheon.get_environments()): """Backup files for all environments (dev, test, live) of a project. """ for env in environments: source = os.path.join(self.server.webroot, self.project, env) local('mkdir -p %s' % self.backup_dir) local('rsync -avz %s %s' % (source, self.backup_dir))
def backup_data(self, environments=pantheon.get_environments()): """Backup databases for all environments (dev, test, live) of a project. """ for env in environments: drupal_vars = pantheon.parse_vhost(self.server.get_vhost_file( self.project, env)) dest = os.path.join(self.backup_dir, env, 'database.sql') self._dump_data(dest, drupal_vars)
def backup_data(self, environments=pantheon.get_environments()): """Backup databases for all environments (dev, test, live) of a project. """ for env in environments: drupal_vars = pantheon.parse_vhost( self.server.get_vhost_file(self.project, env)) dest = os.path.join(self.backup_dir, env, 'database.sql') self._dump_data(dest, drupal_vars)
def get_drupal_update_status(project): """Return dictionary of Drupal/Pressflow version/update information. project: Name of project. """ repo_path = os.path.join('/var/git/projects', project) project_path = os.path.join(pantheon.PantheonServer().webroot, project) environments = pantheon.get_environments() status = dict() with cd(repo_path): # Get upstream updates. local('git fetch origin') # Determine latest upstream version. latest_drupal_version = _get_latest_drupal_version() for env in environments: env_path = os.path.join(project_path, env) with cd(env_path): local('git fetch origin') platform = get_drupal_platform(env_path) drupal_version = get_drupal_version(env_path) # python -> json -> php boolean disagreements. Just use int. drupal_update = int(latest_drupal_version != drupal_version) # Pantheon log only makes sense if already using Pressflow/Pantheon # If using Drupal, the log would show every pressflow commit ever. if platform == 'PANTHEON' or platform == 'PRESSFLOW': pantheon_log = local('git log refs/heads/%s' % project + \ '..refs/remotes/origin/master' ).rstrip('\n') else: pantheon_log = 'Upgrade to Pressflow/Pantheon' # NOTE: Removed reporting back with log entries, so using logs # to determine if there is an update is a little silly. However, # we may want to send back logs someday, so leaving for now. # If log is impty, no updates. pantheon_update = int(bool(pantheon_log)) status[env] = { 'drupal_update': drupal_update, 'pantheon_update': pantheon_update, 'current': { 'platform': platform, 'drupal_version': drupal_version }, 'available': { 'drupal_version': latest_drupal_version, } } return status
def __init__(self, name, project): """Initialize Backup Object. name: name of backup (resulting file: name.tar.gz) project: name of project to backup. """ self.server = pantheon.PantheonServer() self.project = project self.environments = pantheon.get_environments() self.working_dir = tempfile.mkdtemp() self.backup_dir = os.path.join(self.working_dir, self.project) self.name = name + '.tar.gz' self.log = logger.logging.getLogger('pantheon.backup.PantheonBackup') self.log = logger.logging.LoggerAdapter(self.log, {"project": project})
def get_drupal_update_status(project): """Return dictionary of Drupal/Pressflow version/update information. project: Name of project. """ repo_path = os.path.join('/var/git/projects', project) project_path = os.path.join(pantheon.PantheonServer().webroot, project) environments = pantheon.get_environments() status = dict() with cd(repo_path): # Get upstream updates. local('git fetch origin') # Determine latest upstream version. latest_drupal_version = _get_latest_drupal_version() for env in environments: env_path = os.path.join(project_path, env) with cd(env_path): local('git fetch origin') drupal_version = get_drupal_version(env_path) # python -> json -> php boolean disagreements. Just use int. drupal_update = int(latest_drupal_version != drupal_version) # Determine if there have been any new commits. # NOTE: Removed reporting back with log entries, so using logs # to determine if there is an update is a little silly. However, # we may want to send back logs someday, so leaving for now. pantheon_log = local('git log refs/heads/%s' % project + \ '..refs/remotes/origin/master').rstrip('\n') # If log is impty, no updates. pantheon_update = int(bool(pantheon_log)) #TODO: remove the reference to platform once Atlas no longer uses it. status[env] = {'drupal_update': drupal_update, 'pantheon_update': pantheon_update, 'current': {'platform': 'DRUPAL', 'drupal_version': drupal_version}, 'available': {'drupal_version': latest_drupal_version,}} return status