{"action":"closed","issue":{"url":"https://api.github.com/repos/spatie/laravel-backup/issues/391","repository_url":"https://api.github.com/repos/spatie/laravel-backup","labels_url":"https://api.github.com/repos/spatie/laravel-backup/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-backup/issues/391/comments","events_url":"https://api.github.com/repos/spatie/laravel-backup/issues/391/events","html_url":"https://github.com/spatie/laravel-backup/issues/391","id":213688956,"number":391,"title":"Fix for Excluding Tables","user":{"login":"seivad","id":6054798,"avatar_url":"https://avatars1.githubusercontent.com/u/6054798?v=3","gravatar_id":"","url":"https://api.github.com/users/seivad","html_url":"https://github.com/seivad","followers_url":"https://api.github.com/users/seivad/followers","following_url":"https://api.github.com/users/seivad/following{/other_user}","gists_url":"https://api.github.com/users/seivad/gists{/gist_id}","starred_url":"https://api.github.com/users/seivad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seivad/subscriptions","organizations_url":"https://api.github.com/users/seivad/orgs","repos_url":"https://api.github.com/users/seivad/repos","events_url":"https://api.github.com/users/seivad/events{/privacy}","received_events_url":"https://api.github.com/users/seivad/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-13T07:10:49Z","updated_at":"2017-03-14T18:54:39Z","closed_at":"2017-03-14T18:54:39Z","body":"hey guys,\r\n\r\nLove your work! We have some non-critical tables at our start-up that have been going into the backups, so see the code below (I'm not bothering with a pull request but I think it's useful for everyone who uses your plugin). \r\n\r\nIt utilises your exclude tables function the DB Backup package.\r\n\r\n***Add to laravel-backup.php in config folder***\r\n```\r\n'exclude' => [\r\n            // Examples, don't require the database name...\r\n            'notification_archives',\r\n            'notifications',\r\n            'availabilities',\r\n            'unavailabilities',\r\n        ],\r\n```\r\n\r\nthen here is the updated function for creating the files:\r\n\r\n```\r\nprotected static function getDbDumpers(array $dbConnectionNames)\r\n    {\r\n        $dbDumpers = array_map(function ($dbConnectionName) {\r\n            $dbConfig = config(\"database.connections.{$dbConnectionName}\");\r\n            switch ($dbConfig['driver']) {\r\n                case 'mysql':\r\n                    $dbDumper = MySql::create()\r\n                        ->setHost($dbConfig['host'])\r\n                        ->setDbName($dbConfig['database'])\r\n                        ->setUserName($dbConfig['username'])\r\n                        ->setPassword($dbConfig['password'])\r\n                        ->setDumpBinaryPath(isset($dbConfig['dump_command_path']) ? $dbConfig['dump_command_path'] : '')\r\n                        ->setTimeout(isset($dbConfig['dump_command_timeout']) ? $dbConfig['dump_command_timeout'] : null);\r\n                    if (isset($dbConfig['port'])) {\r\n                        $dbDumper->setPort($dbConfig['port']);\r\n                    }\r\n                    if (isset($dbConfig['dump_using_single_transaction']) && $dbConfig['dump_using_single_transaction'] == true) {\r\n                        $dbDumper->useSingleTransaction();\r\n                    }\r\n                    if (!empty(config('laravel-backup.backup.exclude'))) {\r\n                        $exclude = config('laravel-backup.backup.exclude');\r\n                        array_walk($exclude, function (&$table) use ($dbConfig) { $table = ($dbConfig['database'].'.').$table; });\r\n                        $dbDumper->excludeTables($exclude);\r\n                    }\r\n                    return $dbDumper;\r\n                    break;\r\n                case 'pgsql':\r\n                    $dbDumper = PostgreSql::create()\r\n                        ->setHost($dbConfig['host'])\r\n                        ->setDbName($dbConfig['database'])\r\n                        ->setUserName($dbConfig['username'])\r\n                        ->setPassword($dbConfig['password'])\r\n                        ->setDumpBinaryPath(isset($dbConfig['dump_command_path']) ? $dbConfig['dump_command_path'] : '')\r\n                        ->setTimeout(isset($dbConfig['dump_command_timeout']) ? $dbConfig['dump_command_timeout'] : null);\r\n                    if (isset($dbConfig['dump_use_inserts']) && $dbConfig['dump_use_inserts'] == true) {\r\n                        $dbDumper->useInserts();\r\n                    }\r\n                    if (isset($dbConfig['port'])) {\r\n                        $dbDumper->setPort($dbConfig['port']);\r\n                    }\r\n                    return $dbDumper;\r\n                    break;\r\n                default:\r\n                    throw InvalidConfiguration::cannotUseUnsupportedDriver($dbConnectionName, $dbConfig['driver']);\r\n                    break;\r\n            }\r\n        }, $dbConnectionNames);\r\n        return $dbDumpers;\r\n    }\r\n```\r\n\r\n***The new code being:***\r\n```\r\nif (!empty(config('laravel-backup.backup.exclude'))) {\r\n                        $exclude = config('laravel-backup.backup.exclude');\r\n                        array_walk($exclude, function (&$table) use ($dbConfig) { $table = ($dbConfig['database'].'.').$table; });\r\n                        $dbDumper->excludeTables($exclude);\r\n                    }\r\n```\r\n\r\nWould be great if you could add it in to the package. My database backups which were going up to S3 went from 13/14MB to approx 3MB by excluding the non-critical tables.\r\n\r\nP.S. You should get a postcard from us in a few weeks in the mail."}}
{"actor":{"display_login":"freekmurze"}}