I'm running a shared server with multiple users. Each user has their own database in MySQL and associated credentials. I've created a template systemd timer & service (ie. sitetasks@.timer & sitetasks@.service) to run mysqldump daily to backup each users database. User-specific information is read by mysqldump from the .my.cnf file in each users' home directory.
I can then run the systemd timer/service for a specific user (ie. sitetasks@user1.service) to have that user's database backed up.
However, I can't find a way to specify the database name in .my.cnf. I've looked at the --databases option but this is just a flag, not a way to specify a database or set of databases.
I can think of several ways to solve this differently:
- create user-specific systemd timer/service -- but this doesn't scale well
- drop a .db-name file into the users home directory and read it when calling mysqldump (something like mysqldump $(cat .db-name) > backup.sql) - but now I need an additional file
- similar to #2 but parsing each user's wp-config.php (the db's are for Wordpress)
- ensure the db-name is always the same as the user name
None of these are as scalable & portable as being able to use MySQL's existing .my.cnf options file though.
Is there a way to specify a default database name in .my.cnf?