barman does not delete old backups

3,407 views
Skip to first unread message

Wolfgang Neudorfer

unread,
Jul 24, 2013, 3:07:55 AM7/24/13
to pgba...@googlegroups.com
hi,

I'm currently playing around with barman and really love the tool so far - thanks for your efforts!

I perform a daily full backup via a cron job and configured a retention policy of 1 week. I would expect barman to delete older backups as documented in docs.pgbarman.org. However an 8 days old backup does not get deleted (output of barman status):

Retention policies: enforced (mode: auto, retention: RECOVERY WINDOW OF 1 WEEKS, WAL retention: main)
No. of available backups: 8

do I miss something out here?

thanks,

wolfgang

PS: I'm working with barman 1.2.2 on CentOS 6.4 x64.

Wolfgang Neudorfer

unread,
Jul 25, 2013, 2:34:28 AM7/25/13
to pgba...@googlegroups.com
hi again,

something interessting happend today:

I was again checking barman in the morning. As I expected, 9 backups were now available:

current_xlog: 000000010000000000000058 
Retention policies: enforced (mode: auto, retention: RECOVERY WINDOW OF 1 WEEKS, WAL retention: main)
No. of available backups: 9

After that, I started writing a litte bash script that would delete the obsolete backups for me. However, while writing the script, barman deleted the oldest backup himself (I executed barman backup-list a couple of times):

2013-07-25 08:17:56,730 barman.retention_policies INFO: Reporting backup 20130717T102125 for server esp-master as OBSOLETE (older than 2013-07-18 08:17:56.730548)

The latest backup was taken on 20130725T020001, several hours before barman deleted the oldest backup. What triggers barman to delete an obsolete backup?

regards,

wolfgang

Gabriele Bartolini

unread,
Jul 25, 2013, 3:00:32 AM7/25/13
to pgba...@googlegroups.com
Hi Wolfgang,

I apologise for not having had the time to reply to you yesterday. I
would have written the same thing.

On Wed, 24 Jul 2013 23:34:28 -0700 (PDT), Wolfgang Neudorfer
<neudorfer...@gmail.com> wrote:
> 2013-07-25 08:17:56,730 barman.retention_policies INFO: Reporting
> backup 20130717T102125 for server esp-master as OBSOLETE (older than
> 2013-07-18 08:17:56.730548)

When using the recovery window option, you must think in terms of
"Point of recoverability", which is:

NOW() - RECOVERY WINDOW

In your case, you got "2013-07-18 08:17:56.730548" as PoR (Point of
Recoverability). Barman thinks this way:

* The user needs to recover at any time starting from PoR up to now
* You are perfectly aware that PostgreSQL PITR needs a base backup
* Barman keeps the first available base backup before the PoR,
considering the end of time of the backup

For example, consider this scenario.

You take daily backups at 11PM. Your recovery Window is 3 days.
Current time is "2013-07-25 08:55:47.387882+02", which gives a PoR of
"2013-07-22 08:55:47.387882+02".

In order to be able to recovery at any time from PoR and now, Barman
needs to keep the backup taken at 11PM on 21 July, giving you the
following backups in the catalogue:

* 21 July
* 22 July
* 23 July
* 24 July

As you see, it is perfectly normal. You have 4 base backups.

Obsolete backups are deleted by barman cron, automatically (in the
future we might want to manage obsolete backups manually).

I hope this helps!

Cheers,
Gabriele

--
Gabriele Bartolini - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
Gabriele....@2ndQuadrant.it - www.2ndQuadrant.it

Andres Carrion

unread,
May 12, 2015, 10:42:08 AM5/12/15
to pgba...@googlegroups.com, gabriele....@2ndquadrant.it
Hello,

I'm having problems deleting old backups using reuse-backup=copy.

I have my cron configured in this way

bash-4.1$ crontab -l
#Comando para realizar limpieza en el directorio de backup de barman.
* * * * * barman cron
#Crearemos un base backup semanal los Domingos.
#00 06 * * 0 barman backup server
00 06 * * 0 barman backup --reuse-backup=copy server

I made a first complete backup and the other with reuse-backup

There is some strange when I make a barman check server i can see this

Server server:
    ssh: OK
    PostgreSQL: OK
    archive_mode: OK
    archive_command: OK
    directories: OK
    retention policy settings: OK
    backup maximum age: FAILED (interval provided: 7 days, latest backup age: No available backups)
    compression settings: OK
    minimum redundancy requirements: OK (have 0 backups, expected at least 0)

But in my server i can see complete backups

[root@barman-server base]# du -sch *
490G    20150426T060001
503G    20150503T060002
482G    20150510T060001

But the oldes backup 20150426T060001 was not autodelete. for barman cron


I've got configured 2 days in retention policy

retention_policy = RECOVERY WINDOW OF 2 DAYS

last_backup_maximum_age = 7 days

I'm using  CentOS release 6.6 (Final) and barman 1.4.0

What can be the reason for not remove old backups?

And why when i made check server i received that error ??
backup maximum age: FAILED (interval provided: 7 days, latest backup age: No available backups)

When I've got a backup older

[root@barman-server base]# du -sch *
490G    20150426T060001
503G    20150503T060002
482G    20150510T060001


Thanks and best regards
Andres
  Gabriele.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it
Reply all
Reply to author
Forward
0 new messages