SLES11 SP2. I need to create a cron job that will run a rsync backup nightly. I have a script:
Code:
#!/bin/bash

#Script to backup ELC's Share folder to off-site NAS through VPN (Tek-Nerds).
#Specify the mount point here
mount_point='/mnt/backup'

echo "####"
echo ""
#Check to see if the NAS is mounted and if not mount it.
if ! mountpoint -q ${mount_point}/; then
    echo "Mounting the NAS"
    echo "Mount point is ${mount_point}"
    if ! mount ${mount_point}; then
	echo "An error was returned by the mount command!"
	exit 5
    else echo "Mounted successfully";
else echo "${mount_point} is already mounted";
fi

#Target must be mounted at this point, or job dies
if ! mountpoint -q ${mount_point}/; then
    echo "Mounting failed! Cannot run backup without the backup mounted!"
    exit 1
fi

echo "Preparing to transfer files using rsync"

#Use current year to create new backup directory each year
#current_year='date +%Y'

#Specify mount point followed by the path to the bakup directory, finish with current year
#Would like to add month and date
#backup_path=${mount_point}'/EdensLandCorp/'${current_year}
#echo "Backup directory is ${backup_path}"

echo "starting backup of /Share/*..."
rsync --verbose --progress --stats --compress --recursive --times --perms --links --delete /Share/* /mnt/backup 2>&1 | tee /mnt/backup/elc_backup.txt
but i am not ready to use it yet, as i need to figure out the mount_point in the script. I mount a nas to /mnt/backup and have rsync backup to that mount point. What i would like now is to know how to create a cron job that runs this command, nightly and 7:00pm:
Code:
rsync --verbose --progress --stats --compress --recursive --times --perms --links --delete /Share/* /mnt/backup 2>&1 | tee /mnt/backup/elc_backup.txt
Can anyone help me with this?