Browse Source

Make sure you don't backup inside the filestore folder.

The filestore is saved in the backup, so if you save the backup in the
filestore, you'd end up with a huge backup that includes itself and the
universe may collapse.
pull/1158/head
Jairo Llopis 9 years ago
committed by Andrea
parent
commit
e5955aa424
  1. 19
      auto_backup/models/db_backup.py

19
auto_backup/models/db_backup.py

@ -91,10 +91,11 @@ class DbBackup(models.Model):
@api.model
def _default_folder(self):
"""Default to ``backups`` folder inside current database datadir."""
"""Default to ``backups`` folder inside current server datadir."""
return os.path.join(
tools.config.filestore(self.env.cr.dbname),
"backups")
tools.config["data_dir"],
"backups",
self.env.cr.dbname)
@api.multi
@api.depends("folder", "method", "sftp_host", "sftp_port", "sftp_user")
@ -107,6 +108,18 @@ class DbBackup(models.Model):
rec.name = "sftp://%s@%s:%d%s" % (
rec.sftp_user, rec.sftp_host, rec.sftp_port, rec.folder)
@api.constrains("folder", "method")
@api.multi
def _check_folder(self):
"""Do not use the filestore or you will backup your backups."""
for s in self:
if (s.method == "local" and
s.folder.startswith(
tools.config.filestore(self.env.cr.dbname))):
raise exceptions.ValidationError(
_("Do not save backups on your filestore, or you will "
"backup your backups too!"))
@api.multi
def action_sftp_test_connection(self):
"""Check if the SFTP settings are correct."""

Loading…
Cancel
Save