I'm trying to set up a cron job that runs once a week on Sunday. I think I'm supposed to use the "dayofweek" position with it set to 0, but I'm unsure if this overrides the "*" for the day position.
45 2 * * 0 /scripts/backup.sh
Is this correct?
You are correct - as already reported.
Be aware that jobs scheduled for 02:45 on Sundays won't run on the Sunday in the spring when the clocks leap forward (and jobs scheduled for 01:45 on Sundays will run twice on the Sunday in the autumn (fall) when the clocks fall back). Corollary: don't schedule jobs in the 01:00-03:00 window if you might be running them when the clocks change between winter and summer (standard and daylight saving) time.
Also be aware that you can't run jobs on Sunday 1st of any month by adding a '1' to the third (day) column. If you write:
then the command will be run on the 1st of each month regardless of day, and on Sundays, regardless of the day of the month. Counter-intuitively, the day-of-week column is OR'd with the other explicit conditions rather than AND'd. I learned that the hard way - making a public fool of myself. See the POSIX specification for 'crontab', which requires day 0 = Sunday and does not allow day 7 as a synonym.
That's correct. That job will run at 2:45am every Sunday.