by Ken Task.
Sounds like you are on some sort of VPS as provided by 'provider' ... which could put you in a 'jail' so to speak. While it's generally a good security measure to create a separate user with password for an application, one also would need to know what the application needs when it comes to priv's for DB. And certainly be able to use superuser.
Anyyyyy Hooooo ...
Since you know the superuser login/pass for the DB server and you are concerned about locking records during the dump, then combine what tools you have in moodle to do what needs to be done.
In moodlecode/admin/cli/ one will find a maintenance.php script that has options. So to do your sql dump from moodlecode directory:
php admin/cli/maintenance.php --enable;
mysqldump ... command ...;
ls -l /path/to/where/you/saved/thedump/[filename].sql (or *.sql) - see note at bottom for name.
php admin/cli/maintenance.php --disable;
Put all that in a bash shell script in /usr/bin/ ... so you can call it up from anywhere you are located when logged on .. then add a line at beginning ...
cd /path/to/moodlecode/;
Execute rest of the above here.
The maintenance script does have options ... the one provided denies anyone access via browser (including admins - although think now they can use URL direct to /login/index.php to bypass the notice Moodle throws to most users.
You could also do a 'paranoid' version ...
first line of script (this for CentOS) /usr/sbin/services httpd stop
That shuts down apache but you can still use php and mysql commands.
Last line in the script would then restart httpd daemon ...
/sbin/service httpd restart
You'll see:
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
If doing paranoid way ... think I'd also check to see httpd restarted ok by showing the last lines of the httpd error log:
tail /var/log/httpd/error_log
which should display stuff I won't share here but it does end with "resuming normal operations" ... and because one would need to make sure one could:
ps aux |grep httpd
as well as an optional watch of the realtime access logs:
tail -f /var/log/httpd/access_log
Last one would require [ctrl][c] to exit.
Restart of apache will take a little longer but has the added affect of killing off zombie apaches, etc..
NOTE about filename from the dump ... I use a -$(date +%Y%m%d%-H%M%S) variable in the filename of the dumped sql file to save so I can have multiples that won't overwrite the others ... handy IF I ever had to roll back a site ... have matching code directory and data directory backups as well. The Ymd is year month day ... the HMS is hour minute seconds.
'spirit of sharing', Ken