From ac40e1f5acab2984431d89b223251eeb701727d0 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 4 Jul 2018 15:27:02 +0200 Subject: [PATCH 1/2] [ADD] show chatter to make logs accessible --- auto_backup/view/db_backup_view.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/auto_backup/view/db_backup_view.xml b/auto_backup/view/db_backup_view.xml index d1f11e442..3a7fb6313 100644 --- a/auto_backup/view/db_backup_view.xml +++ b/auto_backup/view/db_backup_view.xml @@ -44,6 +44,10 @@
  • Set the scheduler to active and fill in how often you want backups generated.
  • +
    + + +
    From c85d5119e5bcc4fcc229857082acedc43fd78fea Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 4 Jul 2018 16:11:39 +0200 Subject: [PATCH 2/2] [ADD] allow setting an alternative temporary directory --- auto_backup/models/db_backup.py | 20 +++++++++++++++++++- auto_backup/view/db_backup_view.xml | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/auto_backup/models/db_backup.py b/auto_backup/models/db_backup.py index d8a062397..f1fbb09ce 100644 --- a/auto_backup/models/db_backup.py +++ b/auto_backup/models/db_backup.py @@ -6,6 +6,7 @@ import os import shutil +import tempfile import traceback from contextlib import contextmanager from datetime import datetime, timedelta @@ -54,6 +55,11 @@ class DbBackup(models.Model): default="local", help="Choose the storage method for this backup.", ) + tempdir = fields.Char( + string="Temporary directory", + help="Backups first go to a temporary directory. In case you need to " + "put them somewhere else, fill in the directory here", + ) sftp_host = fields.Char( string='SFTP Server', oldname="sftpip", @@ -154,7 +160,8 @@ class DbBackup(models.Model): shutil.copyfileobj(cached, destiny) # Generate new backup else: - db.dump_db(self.env.cr.dbname, destiny) + with rec.custom_tempdir(): + db.dump_db(self.env.cr.dbname, destiny) backup = backup or destiny.name successful |= rec @@ -191,6 +198,17 @@ class DbBackup(models.Model): """Run all scheduled backups.""" return self.search([]).action_backup() + @api.multi + @contextmanager + def custom_tempdir(self): + old_tempdir = tempfile.tempdir + if self.tempdir: + tempfile.tempdir = self.tempdir + try: + yield + finally: + tempfile.tempdir = old_tempdir + @api.multi @contextmanager def backup_log(self): diff --git a/auto_backup/view/db_backup_view.xml b/auto_backup/view/db_backup_view.xml index 3a7fb6313..309473443 100644 --- a/auto_backup/view/db_backup_view.xml +++ b/auto_backup/view/db_backup_view.xml @@ -14,6 +14,7 @@ +