Posted January 7Jan 7 Write a BASH script that performs a backup of a specified directory to a target location. The script should include the following functionality: Basic Requirements: Accept two arguments: Source directory Target backup location Verify that both the source and target locations exist. Create a timestamped backup folder in the target location. Log the backup process, including the time taken and the number of files backed up. Bonus Features: Implement compression (e.g., using tar or zip) for the backup. Add error handling to catch issues like missing arguments or permission errors. Allow for incremental backups by only copying new or modified files. Example Usage: ./backup.sh /home/user/documents /mnt/backup Example Output: Backup started at: 2025-01-06 10:35:21 Backing up /home/user/documents to /mnt/backup/backup_20250106 Number of files backed up: 124 Backup completed in: 2 minutes
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.