Backup Script Not Writing to Log File


Recommended Posts

So our home server runs Debian Linux.  I recently set up a cron job that runs a script I wrote to perform regular backups of our "Storage" drive to our "Backup" drive.  The backups are running properly because new files are included in the "Backup" drive after the job runs, but after the first run, the log file I set up does not get updated.  There's no output from rsync detailing the files that have been updated (even though I can see that the new files were indeed duplicated to the backup drive), not even the "date" line I have set to be written to the log before rsync runs.

 

The very first entry was written just fine, but none after that, even when I manually run the backup script instead of just letting cron run it as root.  I can still manually edit the log file if I want to.

 

Would you guys care to take a look at this script and give me some hints as to why new entries are no longer being added to the log file?

 


#!/bin/bash
#Backup script

 

#A break to make it easy to tell backups apart from one another in the log

echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> /home/marcus/backuplog.txt

 

#Set the date as a variable and writes it to the log file
BACKUPDATE=`date +%Y%m%d%H%M%S`
echo $BACKUPDATE >> /home/marcus/backuplog.txt
echo "" >> /home/marcus/backuplog.txt

 

#Backs up Minecraft server
cp -R /home/marcus/Downloads/minecraft_server /mnt/storage/Backups/minecraft_server_backup_$BACKUPDATE >> /home/marcus/backuplog.txt

 

#Backs up entire storage drive
rsync -av /mnt/storage/ /mnt/backup >> /home/marcus/backuplog.txt
echo "" >> /home/marcus/backuplog.txt

 

#Resets permissions on backup script and backup drives
chown marcus:marcus /home/marcus/backup.sh
chmod 770 /home/marcus/backup.sh
chown -R marcus:marcus /mnt/backup
chmod -R 770 /mnt/backup
chown -R marcus:adams /mnt/storage
chmod -R 775 /mnt/storage

exit
Link to comment
Share on other sites

This topic is now closed to further replies.