Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
KeenWiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Ubuntu
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 8 SQL Backups == Daily automated date marked sql backups should be set up on a production Moodle. Dumps can be large and need to be deleted periodically. * Create MySQL backup user and grant privileges to lock tables (better security than using root or moodleuser roles) * Create a configuration file for root with the backup user credentials (to avoid the password being visible in the SQL backup call). * Set the configuration file permissions to read and write for root only * Setup backup directory with read, write and execute permissions for root only * Set up two daily cron jobs, one to dump the database and the other to remove dumps more than a set number of days old. <syntaxhighlight lang="bash"> BACKUP_USER_PASSWORD=$(openssl rand -base64 6) mysql <<EOF CREATE USER 'backupuser'@'localhost' IDENTIFIED BY '${BACKUP_USER_PASSWORD}'; GRANT LOCK TABLES, SELECT ON moodle.* TO 'backupuser'@'localhost'; FLUSH PRIVILEGES; EOF cat > /root/.my.cnf <<EOF [client] user=backupuser password=${BACKUP_USER_PASSWORD} EOF chmod 600 /root/.my.cnf mkdir -p /var/backups/moodle && chmod 700 /var/backups/moodle && chown root:root /var/backups/moodle (crontab -l 2>/dev/null; echo "0 2 * * * mysqldump --defaults-file=/root/.my.cnf moodle > /var/backups/moodle/moodle_backup_\$(date +\%F).sql") | crontab - (crontab -l 2>/dev/null; echo "0 3 * * * find /var/backups/moodle -name \"moodle_backup_*.sql\" -type f -mtime +7 -delete") | crontab - </syntaxhighlight>
Summary:
Please note that all contributions to KeenWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
KeenWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)