Skip to content

A robust, automated solution to back up sensitive encrypted password files modified in the last 24 hours using Linux Shell Scripting and Cron on .

Notifications You must be signed in to change notification settings

ayoub-chaieb/automatic-backup-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Encrypted Password File Backup Script – backup.sh

🧾 Project Summary

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.


πŸš€ Key Achievements

βœ… 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


πŸ“¦ Features

  • πŸ” 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

πŸ›  Script Usage

./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

πŸ“‚ Example Backup Output

backup-1720895642.tar.gz

Created inside the destination directory, containing only the relevant files updated in the last 24 hours.


πŸ“… Cron Job Configuration

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

πŸ§ͺ Testing Procedure

  1. Deployed important-documents.zip test package
  2. Unzipped and used touch to simulate recent modification timestamps
  3. Executed backup.sh and verified archive generation
  4. Moved script to /usr/local/bin/ and set +x permission
  5. Scheduled cronjob and validated repeated backup creation

πŸ“ Final Directory Structure

.
β”œβ”€β”€ backup.sh
β”œβ”€β”€ important-documents/
β”œβ”€β”€ backup-*.tar.gz
└── /usr/local/bin/backup.sh  # Globally executable

About

A robust, automated solution to back up sensitive encrypted password files modified in the last 24 hours using Linux Shell Scripting and Cron on .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages