Backup table from custom module using backup and migrate
I've had a look at the Backup and Migrate code and I've come up with a solution, one that works for me at least.

I've created a function that gets the default profile data, then alters that to save only the tables I want. It seems to work well but if anyone can see any possible problems with this solution please do let me know.

The function:

&lt;?php
/**
 * @param $tables
 *  An array of table names that will be backed up.
 * @param $filename
 *  Text prepended to the date when naming the backup file.
 */
function _MYMODULE_backup_custom_tables($tables, $filename = 'custom-backup') {
  module_load_include('module', 'backup_migrate');

  // get default profile settings
  backup_migrate_include('files', 'profiles');
  $settings = _backup_migrate_profile_saved_default_profile();

  // set the destination to our private folder
  $settings-&gt;destination_id = 'manual';
  $settings-&gt;source_id = 'db';

  // get a list of all tables from the database
  $schema = drupal_get_schema();
  ksort($schema);
  $drupal_tables = array();
  foreach ($schema as $table =&gt; $table_schema) {
    $drupal_tables[$table] = $table;
  }

  // remove from the database table list the tables we would like to save
  foreach ($tables as $table) {
    unset($drupal_tables[$table]);
  }

  // alter default filters so only the tables we want will be backed up
  $settings-&gt;filters['destinations']['db']['nodata_tables'] = array();
  $settings-&gt;filters['destinations']['db']['exclude_tables'] = $drupal_tables;

  // change the filename so we can identify the backup in the directory
  $settings-&gt;filename = $filename;

  // backup tables
  backup_migrate_perform_backup($settings);
}
?&gt;


The function can then be used like this:

&lt;?php
// the names of the tables we want to save
$tables = array(
  'custom_table_one',
  'custom_table_two',
);

// the text to use when naming the backup file
$filename = 'my-custom-backup';

_MYMODULE_backup_custom_tables($tables, $filename);
?&gt;