This post is part of a series on Drupal update hooks. See Configuration management: update hooks for lazy developers for an introduction to configuration management via update hooks. Drupal 7 stores block information in two separate tables. The 'block' table keeps track of theme specific settings including title, page visibility, region, and weight. The body content for any blocks created through the UI are stored in the 'block_custom' table. The block module provides a handy API function for creating custom blocks. Unfortunately, there are no functions provided for updating the block table. See for a disscussion about the missing block_save() function. For now, we can use an update query to modify the block table directly using block_admin_configure_submit() as a reference. Example:
 * Update the custom logo block.
function monarch_extras_update_7004() {
  // Use a render array for extra credit.
  $value = array(
    '#theme' => 'link',
    '#text' => 'Monarch Digital',
    '#path' => '<front>',
    '#options' => array(
      'attributes' => array(
        'class' => array('monarch-logo'),
  // Build the block edit array.
  $edit = array(
    'info' => 'Monarch Logo',
    'body' => array(
      'value' => render($value),
      'format' => 2, // Full HTML
  // 23 is the custom block id.
  block_custom_block_save($edit, '23');
  // Move the block to the header region and remove the block title.
  $fields = array(
    'region' => 'header',
    'title' => '<none>',
  $query = db_update('block')
    ->condition('module', 'block')
    ->condition('delta', '23')
  // Clear the block from the cache.
  cache_clear_all('block:23', 'cache_block', TRUE);