Backup-MySQL

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Redirecting to Backups#MySQL)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You can, and should backup the MySQL database to a set of SQL commands, which can use used to restore the database, if needed, with the following command:
+
#Redirect [[Backups#MySQL]]
 
+
Run a console (in Windows make sure you run it as administrator)
+
 
+
:mysqldump -u<username> -p<password> -r <location> <databasename>
+
<!-- The command mysqldump -u <username> -p --opt <databasename> > MyOpensimBackup.sql did not work. Maybe used a deprecated syntax, but i did get it working. Also '--opt' is already used by default, no need to include it. -->
+
 
+
Example, assuming that your username is ''admin'', and your password is ''secret'' (Linux/Mac example):
+
mysqldump -uadmin -psecret -r /home/Johnny/OpenSimBackups/OpensimBackup.sql opensim
+
 
+
For Windows ''(testing needed!)'', this would be:
+
mysqldump -uadmin -psecret -r %HOMEPATH%\My Documents\OpenSimBackups\OpensimBackup.sql opensim
+
 
+
Note that there is NO space between -u and the username, and between -p and the password
+
 
+
You will '''not''' be prompted for your password, this makes this command suitable to be used for unattended backups.
+
 
+
==Timestamped Backups==
+
Making a single backup is good. Making daily backups is even better!
+
However, using the command above, it will keep reusing that one file, making it impossible to go back to an earlier date, if needed.
+
 
+
So what we want, is to give the backup a unique, and meaningful name. Here is how:
+
 
+
===Windows===
+
 
+
''<THIS SECTION NEEDS TO BE TESTED!!!>''
+
copy %HOMEPATH%\My Documents\OpenSimBackups\OpensimBackup.sql %HOMEPATH%\My Documents\OpenSimBackups\OpensimBackup%DATE%_%TIME%.sql
+
 
+
===Linux===
+
 
+
mv /home/Johnny/OpenSimBackups/OpensimBackup.sql /home/Johnny/OpenSimBackups/OpensimBackup_$(date +%Y-%m-%d-%H.%M.%S).sql
+
 
+
Instead of issuing this command after the backup has been made, you can append it to the backup command by adding a pipe symbol ('''|''') to the first command. This will let you use the entire line in a cron job.
+
 
+
===Mac===
+
 
+
<unknown, please add Mac version>
+
 
+
 
+
 
+
[[Category:Database]]
+

Latest revision as of 02:35, 4 May 2011

  1. Redirect Backups#MySQL
Personal tools
General
About This Wiki