(backup_dir, backup_name)
return zipfile_path
Creates a zipfile based on a tree created with `create_backup_tree()`.
Creates a zipfile based on a tree created with `create_backup_tree()`.
Creates a zipfile based on a tree created with create_backup_tree () .
def create_backup_zip(backup_dir, backup_name):
    """Creates a zipfile based on a tree created with `create_backup_tree()`."""
    zipfile_fileno, zipfile_path = tempfile.mkstemp()
    zipfile_fd = os.fdopen(zipfile_fileno, "w")
    zf = zipfile.ZipFile(zipfile_fd, "w")

    for dirname, subdirs, files in os.walk(backup_dir):
        for filename in files:
            full_path = os.path.join(dirname, filename)
            rel_path = os.path.relpath(full_path, backup_dir)
            archive_path = os.path.join(backup_name, rel_path)
            zf.write(full_path, archive_path)
            logger.debug("Added to zip: {}".format(archive_path))

    zf.close()
    return zipfile_path
def create_backup_zip ( backup_dir , backup_name ) : zipfile_fileno , zipfile_path = tempfile . mkstemp ( ) zipfile_fd = os . fdopen ( zipfile_fileno , "w" ) zf = zipfile . ZipFile ( zipfile_fd , "w" ) for dirname , subdirs , files in os . walk ( backup_dir ) : for filename in files : full_path = os . path . join ( dirname , filename ) rel_path = os . path . relpath ( full_path , backup_dir ) archive_path = os . path . join ( backup_name , rel_path ) zf . write ( full_path , archive_path ) logger . debug ( "Added to zip: {}" . format ( archive_path ) ) zf . close ( ) return zipfile_path