Make a script to perform the backup and then call it from your crontab.
Here is an example from my system. I dump the filesystem(s) I want across the network to a fileserver. I use ssh to do this. This example probably will not work for you... it is an example. Either modify it for your site or create a whole new model on for your own needs.
Backup script: dump.sched
Code:
#!/bin/sh
PATH=/sbin:/bin:/usr/bin
FILESYSTEMS="ad0s1g"
LOCATION="/usr/data/dmps"
hostname="foobar"
backuphost="fileserver"
backupuser="backups"
perfdump() {
for file in $FILESYSTEMS
do
DUMPFILE="${LOCATION}/L${LEVEL}.N${NUMBER}.${file}.${hostname}.gz"
echo "Dumping ${file}: /dev/$file to ${backuphost}:$DUMPFILE"
dump -${LEVEL}Lau -h 0 -f - /dev/$file | gzip -2 |ssh ${backupuser}@${backuphost} dd of=$DUMPFILE
done
}
dayofmonth=`date | awk 'BEGIN{FS=" "}{print $3}' -`
if [ dayofmonth = "1" ] ;then
LEVEL="0"
NUMBER="0"
else
case `date | awk 'BEGIN{FS=" "}{print $1}' -` in
Sat) LEVEL="9"
NUMBER="1"
;;
Sun) LEVEL="9"
NUMBER="2"
;;
Mon) LEVEL="9"
NUMBER="3"
;;
Tue) LEVEL="9"
NUMBER="4"
;;
Wed) LEVEL="9"
NUMBER="5"
;;
Thu) LEVEL="9"
NUMBER="6"
;;
Fri) LEVEL="5"
NUMBER=`dc << END
$dayofmonth 1-7/pq
END`
;;
*) echo "Error: something went wrong with the date!"
exit 1
;;
esac
fi
perfdump
Crontab entry
Code:
23 4 * * * /root/bin/dump.sched
At 4:23 each morning this script performs the backup for me.
Edit: Wow, it's been a long time since I looked at that script. It could probably be done in a much better manner now. I didn't write it to be the best example of a script -- I just needed something to work.