Initial creation.
This commit is contained in:
parent
24d9725352
commit
cd3f7a80a4
23
backup.sh
Normal file
23
backup.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the required parameters are provided
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <source_folder> <destination_folder>"
|
||||
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"
|
||||
Loading…
x
Reference in New Issue
Block a user