Running a script when no one is logged in
To run a daemon that runs no matter whether you have a user logged in or not you'll want to look at launchd for managing the script that will actually doing the backup. Since Mac OS X 10.4 cron has been replaced by a program called launchd (man page) which combines cron, init.d, rc, and a couple other utilities all into one program.
For reference, launchd runs Launch Agents (run as a user when a user is logged in) and Launch Daemons (run regardless of when a user is logged in). These tasks are defined by xml .plist files that can be found in one of the following locations:
/System/Library/LaunchDaemons
(system tasks - don't modify),
/Library/LaunchAgents
(computer wide tasks that run when any user is logged in),
/Library/LaunchDaemons
(computer wide tasks that run no matter who is logged in),
~/Library/LaunchAgents
(user specific tasks that run when that user is logged in).
More information on the loading, unloading, etc. can all be found on the man page.
The easiest method I've found is to create a shell script to run your backup.
You can then load it and have it run by placing the following .plist file in /Library/LaunchDaemons
and then run sudo launchctl load -w /Library/LaunchDaemons/org.example.script.plist
to load it to run.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.example.script</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/PATH/TO/BACKUP/script.sh</string>
</array>
<key>RunAtLoad</key>
<false/>
<!-- This runs the script every day at 2AM -->
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>2</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
Additionally if you want to edit or create launchd plists I'd recommend looking up Lingon a GUI for editing and creating such .plist files.
Backup script
A really simple backup script could involve the following elements:
1) Mounting the windows file share:
eg.
mkdir /tmp/MountLocation
mount -t smbfs //domain;user:password@server/sharepath /tmp/MountLocation
2) Use rsync to backup the files.
3) Unmount the windows files share when done:
eg.
if [`umount /tmp/MountLocation`]
then
rmdir /tmp/MountLocation
fi
More info about mount -t smbfs
can be found on it's man page or man mount.
Minor Caveats
On the off hand, it should be noted that in Tiger (10.4) StartCalendarInterval has a rather annoying bug when dealing with sleeping that has since been fixed in Leopard (10.5) and later.