LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Backup shell script not working properly (http://www.linuxquestions.org/questions/linux-networking-3/backup-shell-script-not-working-properly-464297/)

jamespetts 07-15-2006 09:41 AM

Backup shell script not working properly
 
I was not sure whether to post this here or in "programming", so apologies if I've got the wrong forum.

In February, I wrote a shell script (using rsync) for automated backups in my home network (a Linux computer running in the bedroom backing up other computers in the house).

However, recently, I have noticed that not all files are backing up: new subdirectories, for example, of directories that the script is set to include will be backed up to the backup volume, but, bizarrely, their contents will not. I have also noticed that e-mail folders don't back up, even though they are set to do so.

I'm not entirely sure what the problem is, and was rather hoping that somebody could help. I will reproduce my backup script below: can anybody spot any flaws?

Code:

#Shell script for home backup using rsync.
#Ver 2.0
#by James E. Petts
#
#
# The following line is the correct crontab entry for this backup script:
# 0 14 * * * /backup/autoback.sh > "/backup/Logs/autoback_`date +%e_%b_%G`.log"
#
echo
echo "*** Automatic backup for PettsNet ***"
echo "Ver 2.0, 19th of February 2006."
echo
echo "Backup commenced at: "
date -R
echo
lastset=`tail -n 1 /backup/Logs/set.log`
if [ $lastset == 0 ]
then
set=1
elif [ $lastset == 1 ]
then
set=0
else
echo "There is an error with the backup sets logfile. Will back up to set 0."
set=0
fi
# ***
echo "Backing up core directories..."
echo
for (( i = 1; i < 10000; i++ ))
do
line=`head -n $i /backup/autoback_core.list | tail -n 1`
if  [ "$line" == EOF ]
then
i=10001
else
echo "Backing up" $line "to backup set" $set ...
rsync -a -v --modify-window=1 --exclude "*.iso" "$line" "/backup/Scheduled Backups/Set"$set
fi
done
echo
# ***
echo "Backing up core directories with /My Videos exclusions..."
echo
for (( i = 1; i < 10000; i++ ))
do
line=`head -n $i /backup/autoback_exclude.list | tail -n 1`
if  [ "$line" == EOF ]
then
i=10001
else
echo "Backing up" $line "to backup set" $set ...
rsync -a -v --modify-window=1 --exclude "My Videos/" "$line" "/backup/Scheduled Backups/Set"$set
fi
done
echo
# ***
echo "Backing up other directories..."
echo
for (( i = 1; i < 10000; i++ ))
do
line=`head -n $i /backup/autoback_others.list | tail -n 1`
if  [ "$line" == EOF ]
then
i=10001
else
echo "Backing up" $line "to backup set 0"...
rsync -a -v --modify-window=1 --exclude "*.iso" "$line" "/backup/Scheduled Backups/Set0"
fi
done
echo
# ***
echo "Backing up deletion reciprocation directories..."
echo
for (( i = 1; i < 10000; i++ ))
do
line=`head -n $i /backup/autoback_delete.list | tail -n 1`
if  [ "$line" == EOF ]
then
i=10001
else
echo "Backing up" $line "to backup set 0"...
rsync -a -v --modify-window=1 --delete --exclude "*.iso" "$line" "/backup/Scheduled Backups/Set0"
fi
done
echo
# ***
echo
echo "Backup finished at:"
date -R
echo
echo `date -R` >> /backup/Logs/set.log
echo $set >> /backup/Logs/set.log
echo "Automated backup software using rsync created by James E. Petts"
echo


spirit receiver 07-15-2006 10:13 AM

Try using rsync with two -v switches, it will tell you why it skips a file.

jamespetts 07-15-2006 11:03 AM

Quote:

Originally Posted by spirit receiver
Try using rsync with two -v switches, it will tell you why it skips a file.

Aha, cunning, thank you, I'll try it :-)


All times are GMT -5. The time now is 06:40 AM.