Restore blocks on Drupal 7 How can I restore the original position (order and initial regions) of blocks on Drupal 7?

I need to make a button that you can restore the block position on Drupal 7. What function or table can be used?
The information about the blocks are saved in the "block" table. The block information is saved in the admin form handled by block_admin_display_form() using the following code.

  foreach ($blocks as $i =&gt; $block) {
    $key = $block['module'] . '_' . $block['delta'];
    $form['blocks'][$key]['module'] = array(
      '#type' =&gt; 'value', 
      '#value' =&gt; $block['module'],
    );
    $form['blocks'][$key]['delta'] = array(
      '#type' =&gt; 'value', 
      '#value' =&gt; $block['delta'],
    );
    $form['blocks'][$key]['info'] = array(
      '#markup' =&gt; check_plain($block['info']),
    );
    $form['blocks'][$key]['theme'] = array(
      '#type' =&gt; 'hidden', 
      '#value' =&gt; $theme,
    );
    $form['blocks'][$key]['weight'] = array(
      '#type' =&gt; 'weight', 
      '#default_value' =&gt; $block['weight'], 
      '#delta' =&gt; $weight_delta, 
      '#title_display' =&gt; 'invisible', 
      '#title' =&gt; t('Weight for @block block', array('@block' =&gt; $block['info'])),
    );
    $form['blocks'][$key]['region'] = array(
      '#type' =&gt; 'select', 
      '#default_value' =&gt; $block['region'] != BLOCK_REGION_NONE ? $block['region'] : NULL, 
      '#empty_value' =&gt; BLOCK_REGION_NONE, 
      '#title_display' =&gt; 'invisible', 
      '#title' =&gt; t('Region for @block block', array('@block' =&gt; $block['info'])), 
      '#options' =&gt; $block_regions,
    );
    $form['blocks'][$key]['configure'] = array(
      '#type' =&gt; 'link', 
      '#title' =&gt; t('configure'), 
      '#href' =&gt; 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure',
    );
    if ($block['module'] == 'block') {
      $form['blocks'][$key]['delete'] = array(
        '#type' =&gt; 'link', 
        '#title' =&gt; t('delete'), 
        '#href' =&gt; 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete',
      );
    }
  }


Using $form_state['values']['blocks'][$key]['module'], and $form_state['values'][$key]['delta'], you can find the block information from that table, and set the form fields to the  values found in the database. In the submission handler for that button, you should also set $form_state['#rebuild'] to TRUE to rebuild the form with the restored values.