cd /home/user/
mkdir .backup
touch folders.txt // include folders in column folder1 folder2 folder3
touch backup.sh
#!/bin/bash
# Define the source and destination base directories
src_base="/media/user/disk1"
dest_base="/media/user/disk2/backup"
# Define the list of folders to copy
folder_list="folders.txt"
# Define the rsync options, including --delete to remove files not present in the source
rsync_opts="-rahP --inplace --info=progress2 --stats -u --delete"
# Loop through each folder in the list
while IFS= read -r folder; do
# Check if the folder path is not empty
if [ -n "$folder" ]; then
echo "Processing folder: $src_base/$folder => $dest_base/$folder"
# Perform the rsync operation
rsync $rsync_opts "$src_base/$folder/" "$dest_base/$folder/"
fi
done < "$folder_list"
chmod +x backup.sh
./backup.sh
cp -ruv /home/user/ /media/user/disk2
No comments:
Post a Comment