diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..b32cb5f --- /dev/null +++ b/backup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Check if the required parameters are provided +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Source and destination folders +source_folder="$1" +destination_folder="$2" + +# Extract the last folder of the source path +source_folder_name=$(basename "$source_folder") + +# Log file path based on the specified format +log_file="/var/log/backup-${source_folder_name}.log" + +# Run rsync with the appropriate options and log the output +rsync -av --delete "$source_folder/" "$destination_folder/" >> "$log_file" 2>&1 + +# Log completion message +echo "Backup completed on $(date)" >> "$log_file"