Get the FTP Backup Cleanup Script: automate archiving old backups and delete redundant files with PHP to optimize your server space.
FTP Backup Cleanup Script automates your entire backup lifecycle—archiving old FTP backups, keeping only the latest files, and deleting redundant copies, all with PHP and a single daily cron job.
Overview
The FTP Backup Cleanup Script is a lightweight, easy-to-configure PHP tool designed for webmasters and system administrators who need a zero-hassle solution to manage FTP backups. Instead of logging in daily and manually purging outdated snapshots, this script runs automatically to:
- Archive the most recent 3 Friday backups and 3 first-of-month backups
- Retain the last 7 daily backups (even if some days are skipped)
- Delete all other redundant or outdated files
- Alert you by email if today’s backup is missing
Key Features
- Daily Retention: Always keep your last 7 FTP snapshots
- Weekly Archives: Automatically archive the latest 3 Friday backups
- Monthly Archives: Automatically archive the first-of-month for the past 3 months
- Automated Cleanup: Remove anything outside your retention policy
- Email Notifications: Instant alerts if a backup fails or is missing
- Easy Configuration: Simply set FTP credentials, directory paths, and retention counts
- Cron-Ready: Schedule a single daily cron job—no manual work ever
Installation & Setup
- Upload
ftp_backup_cleanup.php
to a secure folder on your server (e.g.,/home/username/scripts/ftp_backup_cleanup.php
). - Edit the configuration at the top of the script:
$ftp_server = "ftp.yourdomain.com"; $ftp_user = "ftp_username"; $ftp_pass = "ftp_password"; $backup_dir = "/home/username/backups/"; $archive_dir = "/home/username/archive/"; $daily_keep = 7; $weekly_keep = 3; $monthly_keep = 3; $alert_email = "[email protected]";
- Schedule a daily cron job via cPanel or SSH:
/usr/local/bin/php /home/username/scripts/ftp_backup_cleanup.php >/dev/null 2>&1
- Verify the first run by checking your archive folder and watching for an email alert if today’s backup is missing.
Documentation & Demo
For a detailed walkthrough of how this script works, and to see screenshots of configuration steps, visit our tutorial:
Automate FTP Backup Management: Archive and Delete Redundant Files Automatically with PHP
What’s Included
ftp_backup_cleanup.php
– Fully commented PHP script- Step-by-step Installation & Configuration Guide
- Sample Cron Job command & Email alert template
- One year of free updates and priority email support
Support & Updates
All purchases include one year of free updates and premium email support. If you run into any issues or have questions, please contact our support team.
Reviews
There are no reviews yet.