Back Up Now in the menu bar is fine when you’re sitting at the Mac. When I want a fresh backup as the first step of a script, right before a big cleanup or a round of upgrades, I’d rather have a command that starts the backup and only gives the prompt back once it’s finished. That’s what tmutil startbackup with --block does.
On its own, tmutil startbackup is the same as choosing Back Up Now from the Time Machine menu: it starts a normal backup if one isn’t already running, and your prompt returns straight away. Add --block and it waits for the backup to finish before it exits.
tmutil startbackup --auto --block
The --auto flag runs the backup in a mode similar to the backups macOS schedules by itself. Apple’s man page is careful about that: close to a scheduled backup, but not identical. If you have more than one backup disk, --rotation lets Time Machine rotate between them as it normally would, and --destination with an ID from tmutil destinationinfo sends this one backup to a specific disk.
Where it really pays off is in front of something you might regret:
tmutil startbackup --block && brew upgrade
The && only lets brew upgrade run when tmutil exits with 0, which the man page says it does on success in most situations. Changed your mind halfway? tmutil stopbackup cancels a backup that’s in progress.
One caveat: with --block your terminal is busy for as long as the backup takes. A small hourly increment is quick, but the first backup to a new disk or a backup after you moved a lot of files around can take a long time, so don’t put this in a script you expect to finish in seconds.
Further reading: tmutil man page (SS64 mirror)