[SOLVED] automysqlbackup does not remove old backups

Discussion in 'Installation/Configuration' started by Taleman, Mar 10, 2023.

  1. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I just noticed automysqlbackup on Debian 10 does not remove old backups. I think this is a bug, but it was supposed to be fixed ages ago: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=681856
    The backup file rotation works for daily backup, until the database is removed. Then the rotation no longer happens and old backup files remain. For weekly and montly I have sevaral years old backups.
    Could other users of automysqlbackup check the situation on their host, for example with these commands (if you understand what they do, never run strange code posted by someone on the Internet):
    Code:
    cd /var/lib/automysqlbackup
    for f in monthly/*/* weekly/*/* daily/*/* ; do find $f -depth -mtime +366 -exec ls -lh {} \; ; done
    On my server the command finds 2967 files.
     
    Last edited: Mar 13, 2023
    ahrasis likes this.
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    is that actually a bug?
    i thought it just stopped, because there's no new backup of that database, there's nothing to rotate.
    i think it's actually more useful that way, if someone accidentally deletes the database and no-one bothers checking for a while, (maybe not a popular site) then at least there's still the most recent copy there to restore... it's not been rotated out of existence.
     
    ahrasis likes this.
  3. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    My understanding is automysql backup is supposed to remove old backups, homepage on sourceforge claims as feature "Configurable backup rotation".
    This host was installed in january 2021, montly backups had files beginning March 2021, and every first of month until today, so 25 backups. I do not need backups older than one year.
    Now that I examine more, it seems weekly backups are rotated except for backups on week 48, they remain. This is a known bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030927
    I agree with @nhybgtvfr about delating a database not causing deletion of backups. Automysqlbackup seems to work this way, I noticed old backupfiles for long ago removed databases. Admin just needs to know spring cleaning should purge those ancient backups when they are deemed unnecessary.
    It may be montly backups are not meant to be rotated. I can not find where rotation is supposed to be configured, except by writing my own postbackup script. Perhaps automysqlbackup works as intended, except for the week 48 bug.
     
    ahrasis likes this.
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Use the source, Luke.
    I did not find any documentation about rotation, but reading the source code (bash script) shows:
    Code:
    # Monthly Backups are run on the 1st of the month..
    # Monthly Backups are NOT rotated automatically...
    
    Summary: automysqlbackup works as intended, except the version I have does not rotate weekly backups from week 48. Take care to clean old files occasionally, I got 8.5 GB disk space freed by running:
    Code:
    for f in monthly/*/* weekly/*/* daily/*/* ; do find $f -depth -mtime +366 -delete ; done
     

Share This Page