Skip to content

Commit

Permalink
Merge PR #1442 into 11.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 18, 2019
2 parents e9cf63e + a3314e8 commit 2dd5652
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions auto_backup/models/db_backup.py
Expand Up @@ -232,18 +232,21 @@ def cleanup(self):
now = datetime.now()
for rec in self.filtered("days_to_keep"):
with rec.cleanup_log():
oldest = self.filename(now - timedelta(days=rec.days_to_keep))
bu_format = rec.backup_format
file_extension = bu_format == 'zip' and 'dump.zip' or bu_format
oldest = self.filename(now - timedelta(days=rec.days_to_keep),
bu_format)

if rec.method == "local":
for name in iglob(os.path.join(rec.folder,
"*.dump.zip")):
'*.%s' % file_extension)):
if os.path.basename(name) < oldest:
os.unlink(name)

elif rec.method == "sftp":
with rec.sftp_connection() as remote:
for name in remote.listdir(rec.folder):
if (name.endswith(".dump.zip") and
if (name.endswith('.%s' % file_extension) and
os.path.basename(name) < oldest):
remote.unlink('%s/%s' % (rec.folder, name))

Expand Down

0 comments on commit 2dd5652

Please sign in to comment.