# Maintain and Clean BackWPup Backup Files

This repository contains a Python script designed to help maintain and clean up backup files generated by the WordPress plugin BackWPup. The script filters out specific dates from the backups and deletes the corresponding files, ensuring that only the necessary backups are retained.

## Features

- Generates a matrix of dates for the current year.
- Filters out specific dates (1st, 15th, and 28th of each month).
- Lists and deletes backup files in a specified directory based on the filtered dates.
- Can be easily executed with a single command and a directory parameter.

## Usage

### Prerequisites

- Python 3.x installed on your system.
- The BackWPup plugin installed and configured in your WordPress setup.
- Backup files stored in a specific directory.

### Installation

1. Clone the repository:

   ```bash
   git clone https://github.com/itsChris/BackWPup-MaintainBackupChain.git
   cd maintain_and_clean_backwpup
  1. Make the script executable:

    chmod +x maintain_and_clean_files.py

Running the Script

To run the script, use the following command, replacing /path/to/your/backup/directory with the path to your BackWPup backup directory:

./maintain_and_clean_files.py /path/to/your/backup/directory

Script Details

The script performs the following steps:

  1. Generate Date Matrix: It creates a list of all dates for the current year.
  2. Filter Dates: It excludes the 1st, 15th, and 28th of each month from the list.
  3. Calculate Date Range: It considers dates from January 1st to the end of the last month.
  4. Delete Files: It lists and deletes the backup files in the specified directory that match the filtered dates.

Example Directory Content

An example of backup files in the directory:

2024-05-10_03-30-08_W2XFJ3SZ01.zip  2024-05-31_03-30-50_4SXFJ3SB01.zip  2024-06-20_03-30-00_WGXFJ3VT01.zip
2024-05-11_03-34-16_4OXFJ3WV01.zip  2024-05-31_16-05-34_I6XFJ3QJ01.zip  2024-06-21_03-34-47_FKXFJ3RO01.zip
...

The script will delete files based on the filtered dates.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • This script is tailored for maintaining backups created by the BackWPup WordPress plugin.
  • Thanks to the Python and Open Source communities for their invaluable resources and support.