This update introduces a refined automatic database backup feature during the server startup process and periodic save intervals. The main improvements include:
Conditional Compression: The database backup can now be compressed using gzip. When the compress parameter is set to true, the backup file is compressed, saving disk space. Compression is applied for interval-based saves, which happen every 2 hours, to reduce storage usage over time.
Backup Management: The system now organizes backup files into folders named by date. It also automatically deletes old backups:
Non-compressed backups: Backups older than 7 days are deleted.
Compressed backups: These are deleted after 24 hours, but only if another non-compressed backup is loaded and the compressed file is older than 24 hours.
Automatic Cleanup: Compressed backups are only deleted when a non-compressed backup is being created, and they are older than 24 hours. This mechanism prevents accumulation of outdated compressed backups while ensuring that recent backups remain accessible.
The motivation behind these changes is to create a more efficient and reliable way of managing database backups, ensuring data safety while optimizing storage space usage. The feature can be highly useful for production servers, as it creates backups during startup and periodically, minimizing risks of data loss while efficiently managing disk usage.
Behaviour
Actual
On server startup or during periodic saves, no database backup was created automatically, potentially putting the data at risk of loss. There was no effective mechanism for managing old backup files.
Expected
On server startup, a backup of the entire database is automatically created, including all tables and data types, ensuring data is always safeguarded. Periodic saves occur every 2 hours, and compressed backups are generated. Older backups are managed automatically:
Non-compressed backups older than 7 days are deleted.
Compressed backups older than 24 hours are deleted when a new non-compressed backup is created.
Type of change
[x] New feature (non-breaking change which adds functionality)
How Has This Been Tested
The database backup feature has been tested by:
[x] Running the server multiple times to ensure that backups are correctly created on each startup.
[x] Running periodic saves to verify that compressed backups are created every 2 hours.
[x] Verifying the integrity of the SQL files by restoring the database from both compressed and non-compressed backup files.
[x] Confirming that old backups (both compressed and non-compressed) are properly deleted based on the specified timeframes.
Checklist
[x] My code follows the style guidelines of this project
[x] I have performed a self-review of my own code
[x] I checked the PR checks reports
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
[x] My changes generate no new warnings
[x] I have added tests that prove my fix is effective or that my feature works
Description
This update introduces a refined automatic database backup feature during the server startup process and periodic save intervals. The main improvements include:
Conditional Compression: The database backup can now be compressed using gzip. When the
compress
parameter is set totrue
, the backup file is compressed, saving disk space. Compression is applied for interval-based saves, which happen every 2 hours, to reduce storage usage over time.Backup Management: The system now organizes backup files into folders named by date. It also automatically deletes old backups:
Automatic Cleanup: Compressed backups are only deleted when a non-compressed backup is being created, and they are older than 24 hours. This mechanism prevents accumulation of outdated compressed backups while ensuring that recent backups remain accessible.
The motivation behind these changes is to create a more efficient and reliable way of managing database backups, ensuring data safety while optimizing storage space usage. The feature can be highly useful for production servers, as it creates backups during startup and periodically, minimizing risks of data loss while efficiently managing disk usage.
Behaviour
Actual
On server startup or during periodic saves, no database backup was created automatically, potentially putting the data at risk of loss. There was no effective mechanism for managing old backup files.
Expected
On server startup, a backup of the entire database is automatically created, including all tables and data types, ensuring data is always safeguarded. Periodic saves occur every 2 hours, and compressed backups are generated. Older backups are managed automatically:
Type of change
How Has This Been Tested
The database backup feature has been tested by:
Checklist