I successfully delivered a robust, automated solution to back up sensitive encrypted password files modified in the last 24 hours. The deliverable was a fully functional Bash script (backup.sh
) scheduled via cron
, ensuring daily, secure, and timestamped archiving of updated credentials.
β
Developed a modular, well-documented Bash script for secure backups
β
Implemented timestamp-based logic to detect file changes within the last 24 hours
β
Used array handling to dynamically collect files eligible for backup
β
Created compressed tarball backups with precise naming convention
β
Deployed the script to /usr/local/bin/
and verified execution permissions
β
Validated behavior with sample sensitive documents and manual triggering
β
Automated execution using cron, scheduled every 24 hours
β
Confirmed backup file creation and proper destination placement
- π Change Detection: Backs up only the files modified in the past 24 hours
- π°οΈ Timestamped Backups: Ensures traceability with naming like
backup-<timestamp>.tar.gz
- π Secure Handling: Focused on encrypted password file scenarios
- π§° Portable CLI Tool: Script installed under
/usr/local/bin
for universal access - π Cron Integration: Seamless daily backups without manual intervention
./backup.sh <targetDirectory> <destinationDirectory>
π Example:
./backup.sh important-documents /home/project
The script will:
- Scan
important-documents/
for updated files - Archive and compress them
- Output
backup-<timestamp>.tar.gz
to/home/project
backup-1720895642.tar.gz
Created inside the destination directory, containing only the relevant files updated in the last 24 hours.
To automate the script execution every 24 hours, a cron job was created with:
0 0 * * * /usr/local/bin/backup.sh /path/to/source /path/to/destination
During testing, the cron service was manually started in the environment using:
sudo service cron start
β¦and stopped afterward with:
sudo service cron stop
- Deployed
important-documents.zip
test package - Unzipped and used
touch
to simulate recent modification timestamps - Executed
backup.sh
and verified archive generation - Moved script to
/usr/local/bin/
and set+x
permission - Scheduled cronjob and validated repeated backup creation
.
βββ backup.sh
βββ important-documents/
βββ backup-*.tar.gz
βββ /usr/local/bin/backup.sh # Globally executable