Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Improve backup retention (for database backups) #4818

Merged
merged 13 commits into from
Jan 14, 2025

Conversation

peaklabs-dev
Copy link
Member

@peaklabs-dev peaklabs-dev commented Jan 13, 2025

Changes

  • feat: Retention Options (whichever limit is reached first will trigger the cleanup):
    • Number of backups to keep -> A number of backups to keep
    • Days to keep backups -> A number of days to keep backups
    • Maximum storage (GB) -> A number of GB or decimal of maximum allowed storage for this backup job
  • feat: add backup retention days, backup amount and max allowed storage to S3
  • feat: add backup retention days and max allowed storage to locally stored backups
  • feat: when deleting a backup schedule you can now select to delete all backups form S3 as well
  • feat: when deleting a single backup you can now select to delete the backup form S3 as well
  • feat: New backup retention UI:
image
  • feat: Multi-delete on S3 and locally stored backups -> Now multiple backup files and backup executions are deleted together in parallel for improved performance and faster executions of deletion...
  • fix: only call removeOldBackups function in the DatabaseBackupJob.php if the backup is completed and successful, this caused problems before
  • fix: delete backup folder and parent folder if folders are empty when deleting local backups to cleanup unused folders
  • fix: Do not remove executions from DB until both S3 and local backups have been deleted and successfully processed otherwise backups will never be deleted from s3.
  • refactor: refactored the UI and DB to make it easier to use - 0 now means unlimited retention (so a value is now required for retention).
  • refactor: simplified some code
  • refactor: refactored some duplicated code
  • refactor: refactored code to be more centralized in one location
  • chore: use CamleCase everywhere for new functions
  • chore: renamed number_of_backups_locally to database_backup_retention_amount_locally

Note

  • Most S3 providers have a cooldown of 24 hours or more on files deleted via the API for security reasons, so if you set your retention days in Coolify to 7 days, files older than 7 days will be hidden (deleted) in your bucket (and still consume storage) for 24+ hours more and then they will be permanently deleted on the 8th day or later, depending on the provider.

Issues

/claim #4782

- rename number_of_backups_locally to database_backup_retention_amount_locally
- add backup retention days to local stored backups
- add s3 retention fields
- use the new removeOldBackups function
- only call removeOldBackups function when the backup is completed and also only if the backup is successful
- fix: Delete folder and parent folder if folders are empty when deleting local backups.
- fix: Do not remove executions from DB until both S3 and local backups have been deleted and successfully processed otherwise backups will never be deleted from s3.
- fix: Server ID could be null
- feat: add storage retention to local storage as well
- fix: UI input for max storage now allows exact decimals so MB input is now also possible
- fix: Database column is now decimal instead of integer
- fix: variable naming of storage check no longer overwrites $backup - renamed it to $backupExecution
@peaklabs-dev peaklabs-dev changed the title Feat: Improves backup retention (for database backups) Feat: Improve backup retention (for database backups) Jan 13, 2025
@peaklabs-dev peaklabs-dev marked this pull request as ready for review January 13, 2025 20:36
@peaklabs-dev peaklabs-dev added the 🏔️ Peaklabs A label for PRs from Peaklabs. label Jan 13, 2025
@andrasbacsai
Copy link
Member

Thank you for the PR! I love it!

@andrasbacsai andrasbacsai merged commit b01ea8b into coollabsio:next Jan 14, 2025
1 check passed
@github-actions github-actions bot removed the 🏔️ Peaklabs A label for PRs from Peaklabs. label Jan 14, 2025
@peaklabs-dev peaklabs-dev deleted the feat-backup-retention branch January 14, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants