I'm trying to write a script to use rsync to backup my data regularly.
Everything seems to work on its own, but when I use cron to run it daily
there's a small but critical problem. The script ("choose_bu") runs,
rsync runs, but terminates immediately (well, within 1 second) and no
new or changed files are copied to the backup set. Running choose_bu or
choose_bu -f from the command line both work perfectly well.
So, any idea what could be happening? I know the cron call works, I know
choose_bu works, what's preventing them working together?
Appended below are the script, the crontab listing and the output from
the script.
The choose_bu script:
--------------------
#! /bin/bash
if test X$1 = X-f
then
fullbu=0
message_out='Full'
else
fullbu=1
message_out='Incremental'
fi
echo Started $message_out backup at:
date
#The directory to back up
folder=/home/$USER
#The backup directory/drive
backup=/media/Samsung
if test $fullbu = 0 ; then
rm -fr $backup/oldbu
mv $backup/steve $backup/oldbu
fi
rsync -avzu --exclude-from=$folder/Documents/Techie/bu_exclude $folder
$backup
echo Completed $message_out backup at:
date
*******************************************
Crontab:
--------
steve@Ubuntu-A:~$ crontab -l
0 3 * * 1-6 Documents/Techie/choose_bu > Desktop/output # JOB_ID_2
0 3 * * 7 Documents/Techie/choose_bu -f > Desktop/output # JOB_ID_3
steve@Ubuntu-A:~$
*********************************************
Content of /Desktop/output:
---------------------------
Started Incremental backup at:
Mon May 31 03:00:01 BST 2010
running incremental backup
Completed Incremental backup at:
Mon May 31 03:00:01 BST 2010
*******************************************