def app_backup(storage, full_bucket_name=None):
 if (not makedirs(APP_BACKUP_DIR_LOCATION)):
  logging.warning("Dir '{0}' already exists. Skipping dir creation...".format(APP_BACKUP_DIR_LOCATION))
 for (dir_path, _, filenames) in os.walk(APP_DIR_LOCATION):
  for filename in filenames:
   source = '{0}/{1}'.format(dir_path, filename)
   destination = '{0}/{1}'.format(APP_BACKUP_DIR_LOCATION, filename)
   try:
    shutil.copy(source, destination)
   except Exception:
    logging.error("Error while backing up '{0}'. ".format(source))
    delete_app_tars(APP_BACKUP_DIR_LOCATION)
    return False
   if (storage == StorageTypes.GCS):
    source = '{0}/{1}'.format(APP_DIR_LOCATION, filename)
    destination = '{0}/apps/{1}'.format(full_bucket_name, filename)
    logging.debug('Destination: {0}'.format(destination))
    if (not gcs_helper.upload_to_bucket(destination, source)):
     logging.error("Error while uploading '{0}' to GCS. ".format(source))
     delete_app_tars(APP_BACKUP_DIR_LOCATION)
     return False
 return True

def app_backup ( storage , full_bucket_name = None ) : if ( not makedirs ( APP_BACKUP_DIR_LOCATION ) ) : logging . warning ( "Dir '{0}' already exists. Skipping dir creation..." . format ( APP_BACKUP_DIR_LOCATION ) ) for ( dir_path , _ , filenames ) in os . walk ( APP_DIR_LOCATION ) : for filename in filenames : source = '{0}/{1}' . format ( dir_path , filename ) destination = '{0}/{1}' . format ( APP_BACKUP_DIR_LOCATION , filename ) try : shutil . copy ( source , destination ) except Exception : logging . error ( "Error while backing up '{0}'. " . format ( source ) ) delete_app_tars ( APP_BACKUP_DIR_LOCATION ) return False if ( storage == StorageTypes . GCS ) : source = '{0}/{1}' . format ( APP_DIR_LOCATION , filename ) destination = '{0}/apps/{1}' . format ( full_bucket_name , filename ) logging . debug ( 'Destination: {0}' . format ( destination ) ) if ( not gcs_helper . upload_to_bucket ( destination , source ) ) : logging . error ( "Error while uploading '{0}' to GCS. " . format ( source ) ) delete_app_tars ( APP_BACKUP_DIR_LOCATION ) return False return True
saves the app source code at the backups location on the filesystem .