I've noticed that the backup files get exponentially larger as time passes on daily backups unless all caches are cleared on a site. Recently I found that a moderately sized website with ~500 nodes had a backup file as large as 530MB. After I cleared all caches, the backup saved was 14MB.

Is there something we can do to avoid this?

Comments

awasson created an issue. See original summary.

szeidler’s picture

You should exclude the cache data with selecting all cache-related tables. That can be done when you add a new/edit an existing settings profile at /admin/config/development/backup_migrate/settings. And then exclude the cache table data in the select field called Exclude data from these tables
.

When you use that settings profile for your exports, you don't need to flush the caches in the production system anymore and your backups should be drastically smaller.

ronan’s picture

Title: Backups are massive prior to flush all caches » Exclude cache table contents by default
Category: Bug report » Feature request

This should be the default (as it was in previous versions) updating issue to reflect that.

couturier’s picture

Version: 8.x-4.0-alpha1 » 8.x-4.0-alpha2

Updating the version.

szeidler’s picture

Status: Active » Needs review
StatusFileSize
new880 bytes

The patch excludes the default cache tables by default and use them also as default excluding tables when creating a new profile.

imyaro’s picture

Probably we should also include table "cache" ?
Also I don't see "cache_block" in the list.

szeidler’s picture

Do you find those tables in Drupal8? I cannot see them in my installation.

nancydru’s picture

I would exclude everything identified thusly (7.x):

  $core = array('cache', 'cache_path', 'cache_filter', 'cache_bootstrap', 'cache_page');
  $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
szeidler’s picture

It's a good idea, but I cannot find a way to clearly identify the cache table names. I stuck in

$module_handler = \Drupal::moduleHandler();
$module_handler->invokeAll('cache_flush');
foreach (\Drupal\Core\Cache\Cache::getBins() as $service_id => $cache_backend) {
  // There are useful information in $cache_backend, but only protected and not accessible.
}

but cannot extract the necessary CacheBackend information out of it. (Also not all `cache_*` tables were present in that loop.)

Alex Andrascu’s picture

I've managed to identify the following tables that shouldn't export any data.
If anyone knows different please feed back.

      $config = [
        'exclude_tables' => [],
        'nodata_tables' => [
          'cache_advagg_minify',
          'cache_bootstrap',
          'cache_config',
          'cache_container',
          'cache_data',
          'cache_default',
          'cache_discovery',
          'cache_discovery_migration',
          'cache_dynamic_page_cache',
          'cache_entity',
          'cache_menu',
          'cache_migrate',
          'cache_render',
          'cache_rest',
          'cache_toolbar',
          'sessions',
          'watchdog',
          'webprofiler',
        ],
      ];

Longer term we'll probably need a more elegant solution to this issue but for now we'll have to go with it.

  • Alex Andrascu committed ac58889 on 8.x-4.x authored by szeidler
    Issue #2831297 by szeidler, Alex Andrascu: Exclude cache table contents...
Alex Andrascu’s picture

Slightly modified version of patch in #5 pushed to dev.

Alex Andrascu’s picture

Status: Needs review » Reviewed & tested by the community
Alex Andrascu’s picture

Version: 8.x-4.0-alpha2 » 8.x-4.x-dev
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dercheffe’s picture

Would like to reopen this issue to add the tables "cache_page" and "cachetags" for excluding by default. what do you think about?

couturier’s picture

@dercheffe Since this patch has been committed last year, I'm not sure the procedure. Can someone advise as to whether we should open a new issue for this?