static int do_delete_backups(struct sdirs *sdirs, struct conf *cconf) { int ret=-1; int deleted=0; unsigned long m=1; struct bu *bu=NULL; struct bu *last=NULL; struct bu *bu_list=NULL; struct strlist *keep=NULL; if(bu_list_get(sdirs, &bu_list)) goto end; // Find the last entry in the list. for(bu=bu_list; bu; bu=bu->next) last=bu; // For each of the 'keep' values, generate ranges in which to keep // one backup. for(keep=cconf->keep; keep; keep=keep->next) { unsigned long rmin=0; rmin=m * keep->flag; if(keep->next && range_loop(sdirs, cconf, keep, rmin, bu_list, last, &deleted)) goto end; m=rmin; } // Remove the very oldest backups. for(bu=bu_list; bu; bu=bu->next) if(bu->trbno>m) break; for(; bu; bu=bu->prev) { if(delete_backup(sdirs, cconf, bu)) goto end; deleted++; } ret=deleted; end: bu_list_free(&bu_list); return ret; }
static int do_delete_backups(struct sdirs *sdirs, const char *cname, struct strlist *keep, struct bu *bu_list, const char *manual_delete) { int ret=-1; int deleted=0; unsigned long m=1; struct bu *bu=NULL; struct bu *last=NULL; struct strlist *k=NULL; // Find the last entry in the list. for(bu=bu_list; bu; bu=bu->next) last=bu; // For each of the 'keep' values, generate ranges in which to keep // one backup. for(k=keep; k; k=k->next) { unsigned long rmin=0; rmin=m * k->flag; if(k->next && range_loop(sdirs, cname, k, rmin, bu_list, last, manual_delete, &deleted)) goto end; m=rmin; } // Remove the very oldest backups. for(bu=bu_list; bu; bu=bu->next) if(bu->trbno>m) break; for(; bu; bu=bu->prev) { if(delete_backup(sdirs, cname, bu, manual_delete)) goto end; deleted++; } ret=deleted; end: return ret; }