This Bash script automates the backup of a specified directory, allowing you to run it at scheduled intervals. The script checks if 24 hours have passed since the last backup and, if so, initiates a new backup.
- Automated Backup: The script automatically backs up a specified directory.
- Scheduled Backups: You can schedule the script to run at specific intervals.
- Log Files: Logs are maintained to keep track of backup activities.
Before using the script, ensure you have the following prerequisites:
- Bash (shell scripting environment)
- Tar command (for creating compressed archives)
- Cron (for scheduling automated backups)
-
Clone the repository or download the script to your local machine.
git clone https://github.com/hima890/backup-script.git
-
Make the script executable.
chmod +x backup_script.sh
Edit the config.txt file to set the paths and configurations:
# Specify the path to your project folder
directory_to_compress="/path/to/your/project"
# Specify the path to your backup folder
backup_folder="/path/to/your/backup/folder"Run the script manually:
./backup_script.shThis will prompt you to initiate the backup. Follow the instructions to proceed.
To schedule the script to run automatically, add a cron job:
-
Open the crontab editor:
crontab -e
-
Add a cron job entry to run the script every day at midnight:
0 0 * * * /path/to/your/backup_script.sh >/dev/null 2>&1 &
Save and exit the crontab editor.
Logs are maintained in the backup_log.txt file. This file contains timestamps and messages related to backup activities.
This project is licensed under the MIT License.