Files
Automatic_Back-Ups/backup_routine.sh
2022-05-27 15:36:00 +02:00

31 lines
699 B
Bash

#!/bin/bash
IFS=$'\r\n' GLOBIGNORE='*' command eval 'FILES=($(cat backup_filelist.txt))'
for i in "${FILES[@]}"
do
FILENAME=$(basename "$i")
if [ -f "$FILENAME" ]; then
#echo "$FILENAME exists."
DIF=$(diff "$i" "$FILENAME")
if [ -z "$DIF" ]
then
#echo "$FILENAME has not changed, skipping."
else
#echo "$FILENAME has changed, copying..."
cp "$i" .
fi
else
#echo "$FILENAME does not exist, copying..."
cp "$i" .
fi
done
if [[ `git status --porcelain` ]]; then
#echo "Git reports changes. Perfoming next generic commit."
git add *
git commit -m "next commit"
else
#echo "Git doesn't report any changes. No new commit. Exiting."
fi