An automated backup solution that utilizes rsync for efficient file synchronization and integrates with an API to notify system owners of the backup status. The script facilitates the process of backing up files from a local directory to a remote server, logs detailed transfer information, and sends notifications to a specified API endpoint once the backup is complete.
This solution was designed to streamline the backup process, ensuring reliability with minimal manual intervention, and providing system owners with real-time updates on the status of their backups.
The script automates the backup process by syncing files from a local directory to a remote server using rsync. After the transfer is complete, the script logs key details, such as the total size of the transferred files, and sends these details to an API endpoint in the form of a JSON payload. This notification triggers an email(via the PHP Mailer API) to the system owner, informing them whether the backup was successful or if any issues occurred.
Backup ProcessThe script begins by setting up the local and remote directories, SSH key, and other necessary configurations. It then runs rsync to synchronize the files. After theprocess completes, the script captures the start and end times, along with the total size of the transferred files.
API Notification:
Once the backup is complete, a JSON payload containing the backup status, start and end times, file details, and server information is sent to the API endpoint.This triggers the corresponding email notifications, keeping the system owner informed of the backup’s status.
The source code for this project is not publicly available.
Please fill out the contact form below, and I’ll get back to you with the necessary details.