Backup-MySQL
From OpenSimulator
Contents |
Making A Backup of your MYSQL Database
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.
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>