A database backup that sits uncompressed next to your site is a small mess waiting to happen. I prefer the dump to go straight into a compressed file.
WP-CLI can write a database export to standard output instead of a file. You give it a single dash as the file name, and then you pipe it wherever you like. It runs mysqldump with the credentials from your wp-config.php, so you never type a password.
wp db export - | gzip > backup-$(date +%F).sql.gz
The result is one compressed file with today’s date in the name. If you only need part of the data, add --tables=wp_posts,wp_postmeta or leave something out with --exclude_tables. Restoring goes the other way: gunzip -c backup.sql.gz | wp db import -, because import also accepts a dash for standard input.
The caveat: a dump is only the database. Your uploads, themes and plugins live in the file system, so this is half a backup at best. Also, the table prefix in the examples is the default wp_. Yours may differ, so run wp db tables first if you want to name tables.
Without the dash, WP-CLI names the file after the database, the date and a random hash. That is fine, but it makes scripting a pain. I like a name I can predict.
Further reading: wp db export (WP-CLI command reference), On this site: wp core verify-checksums tells you if someone touched your WordPress files, On this site: wp option list –autoload=on –format=total_bytes shows what every page load drags along