Ubuntu – backup thesql directory

backupMySQLpermissionsUbuntu

I had created a script that uses rsync to backup some directories of the production servers to a dedicated one. I would also like to perform a backup of the directory /var/lib/mysql/some_database.

As cron task that executes the backup is associated to a user different than root, I need to set some permissios on the /var/lib/mysql/ directory.

As far as I know, it is only needed that the user can navigate (execute) through the some_database/ directory and the files that are placed inside it, have read permissions.

Which are the more proper permissions that I should use?

Thanks in advance for the help,
Best regards!

Best Answer

doing a backup of /var/lib/mysql is not a good idea, because the mysql daemon needs to be stopped before.

use tools like mysqldump to dump the databases into a file in e.g. /var/backups/mysql/ or whereever and backup these files

the dump of the databases can be started by the user creating the backup, so there will be no problems. but think of removing rights on the folder for group and world if you do not need them