diff --git a/README.rst b/README.rst index d88ab69a..7accfa10 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,8 @@ filename. :: Specify filename on storage -O OUTPUT_PATH, --output-path=OUTPUT_PATH Specify where to store on local filesystem + -x EXCLUDE_TABLES, --exclude-tables=EXCLUDE_TABLES + Exclude tables data from backup (-x 'public.table1, public.table2') dbrestore --------- diff --git a/dbbackup/management/commands/dbbackup.py b/dbbackup/management/commands/dbbackup.py index cc85e84a..541e8d89 100644 --- a/dbbackup/management/commands/dbbackup.py +++ b/dbbackup/management/commands/dbbackup.py @@ -32,7 +32,9 @@ class Command(BaseDbBackupCommand): make_option("-o", "--output-filename", default=None, help="Specify filename on storage"), make_option("-O", "--output-path", default=None, - help="Specify where to store on local filesystem") + help="Specify where to store on local filesystem"), + make_option("-x", "--exclude-tables", default=None, + help="Exclude tables from backup") ) @utils.email_uncaught_exception @@ -49,6 +51,7 @@ def handle(self, **options): self.filename = options.get('output_filename') self.path = options.get('output_path') + self.exclude_tables = options.get("exclude_tables") self.storage = get_storage() self.database = options.get('database') or '' @@ -56,6 +59,8 @@ def handle(self, **options): for database_key in database_keys: self.connector = get_connector(database_key) + if self.connector and self.exclude_tables: + self.connector.exclude.extend(list(self.exclude_tables.replace(" ", "").split(','))) database = self.connector.settings try: self._save_new_backup(database)