jajuk-team / jajuk

Advanded jukebox for users with large or scattered music collections
49 stars 19 forks source link

Better backup management algorithm #1667

Open bflorat opened 9 years ago

bflorat commented 9 years ago

Reported by mats ahlgren on 27 May 2010 20:00 UTC One might think this would lead to a massive usage of disk space. Whenever Jajuk closes (and only after it successfully saves collection.xml) it should look through the .jajuk folder to see which collections it can throw away. The following algorithm should work I think:

// Always keep the last 5 backups.
allBackupFiles = allBackupFiles.slice(all elements from left until index -5 from right)

let D = [of the 5th-latest backup](date)

for(DateRange range in {0-1day, 1day-1week, 1week-1month, 1month-1year, 1year-forever}) {
    backupsInRange = new List;
    for (backupFile in allBackupFiles)
        if ((D-backupFile.date) in range)
            backupsInRange.add

    backupsInRange.remove(index=mostRecent); // don't delete most recent backup in range
    backupsInRange.remove(index=leastRecent); // don't delete oldest backup in range: necessary else backups will never trickle to older ranges
    for (backupFile in backups) // delete old backups
        backupFile.deleteFromDisk();
}

Also,

Collection files should be saved with names that include the version of Jajuk. e.g. collection-backup--2010-05-08--04:17--v1.9RC3.xml

bflorat commented 9 years ago

Commented by bflorat on 27 May 2010 20:01 UTC OK but limit should be against the max size option already available in jajuk instead of a fix number of backup files.