Backup-MySQL

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
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:
 +
 
Run a console (in Windows make sure you run it as administrator)
 
Run a console (in Windows make sure you run it as administrator)
  
Backup the MySQL data base to a set of SQL commands which can use used to restore the data baseE.g. with
+
: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===
  
mysqldump -u <username> -p --opt <databasename> > MyOpensimBackup.sql
+
<unknown, please add Mac version>
  
You will be prompted for your password. --opt really is two hyphens.
 
  
  
 
[[Category:Database]]
 
[[Category:Database]]

Revision as of 01:43, 22 November 2010

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:

Run a console (in Windows make sure you run it as administrator)

mysqldump -u<username> -p<password> -r <location> <databasename>

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.

Contents

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>

Personal tools
General
About This Wiki