CodeForPhilly / clean-and-green-philly

Dashboard to target Philly vacant properties for anti-gun violence interventions
https://www.cleanandgreenphilly.org/
MIT License
32 stars 60 forks source link

Prune old tile file backups and detailed diff reports from GCP bucket #706

Open zigouras opened 3 months ago

zigouras commented 3 months ago

Describe the task

The backup and diff functionality ends with a pruning of old backed up schemas older than a configured number of days, currently 365. This is to save space in the database. Similarly, we can delete the timestamped backed up tile files and detailed diff reports from the Google Cloud bucket.

Currently, the tiles files backups are generated after every run of the back-end script, regardless of whether a reload is forced or not, and never deleted. The detailed diff reports are generated if there are any differences found during a run of the back-end script with forced reloading, and never deleted.

The tiles file backups are in the format backups/name_%Y_%m_%dt%H_%M_%S.ext, e.g. backup/vacant_properties_tiles_2024_06_02t17_17_08.pmtiles or backup/vacant_properties_tiles_staging_2024_06_02t16_34_41.pmtiles

The detailed diff reports are in the format diff/%Y_%m_%dt%H_%M_%S/table_name.html, e.g. diff/2024_05_10t14_50_53/vacant_properties.html.

Using the same cutoff as used to prune the old postgres schema backups define in config.py::max_backup_schema_days, delete the old tiles file backups and detailed diff report folders after a force reload run of the back-end script.

Acceptance Criteria

Coding of the above requirement plus unit tests to assert functionality.

Additional context

The existing Python function backup_archive_database.py::BackupArchiveDatabase::prune_old_archives. Issues #520, #662.

github-actions[bot] commented 1 day ago

This issue has been marked as stale because it has been open for 30 days with no activity.