Backups

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Merged the following pages -> "Backup-MySQL", "Backup-PostgreSQL", "Backup-SQLite", "Backup-db". Then I will look into "Backup"(not "s"))
Line 1: Line 1:
Making backups of your configuration files and data is essential.  There are two basic types of data that need to be backed up.
+
{{Template:Quicklinks}}
* [[Backup-local|Local Files]] - These include your region files and configuration files.
+
Making backups of your configuration files and data is essential.  
* [[Backup-db|Database]] - This is all the data in your database.  This assumes that you have control over your grid/standalone.
+
  
 
If necessary, you can also back up regions by using [[OpenSim_Archives|OpenSim Archives (OARs)]] and inventory using [[Inventory_Archives|Inventory Archives]].  If you don't run your own grid, then this is a way to back up your data locally.
 
If necessary, you can also back up regions by using [[OpenSim_Archives|OpenSim Archives (OARs)]] and inventory using [[Inventory_Archives|Inventory Archives]].  If you don't run your own grid, then this is a way to back up your data locally.
 +
 +
 +
 +
=Local Files=
 +
The following files need to be saved:
 +
* Configuration files
 +
** OpenSim.ini
 +
** All files in config-include/
 +
** All region .xml or .ini files in Regions/
 +
** If you are running in grid mode, the various .xml configuration files. I using ROBUST Services a range of other .ini files for the various services must now also be backed up.
 +
 +
Feel free to add more if I've missed anything.
 +
 +
 +
 +
= SQLite =
 +
Since SQLite saves its databases as local files, it's fairly simple to back it up.
 +
* Stop OpenSim
 +
* Copy all of the *.db files out of the /bin directory (assuming that you haven't changed this in the OpenSim.ini file) to wherever you want them saved.
 +
 +
 +
 +
= MySQL =
 +
==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 terminal 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!!!>''
 +
move %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>
 +
 +
==Automatic Daily Backups==
 +
===Windows===
 +
<Example needed>
 +
 +
===Linux===
 +
This example is very Ububtu centered. Please add modifications for other distros, if/when needed.
 +
 +
In this example, we will assume that the username is ''admin'', and the password is ''secret''.
 +
 +
*Open a text editor, and paste the following.
 +
 +
#!/bin/bash
 +
  #Change to the folder where the files should be saved, for ease of use.
 +
cd /home/Johnny/OpenSimBackups/
 +
 +
  #Make a backup of the opensim database
 +
mysqldump -uadmin -psecret -r OpensimBackup.sql opensim
 +
 +
  #Tricky one! Compresses the backup file, and appends time and date.
 +
  #This saves disk space, and lets you go back to an earlier date if needed.
 +
tar -czf OpensimBackup_$(date +%Y-%m-%d-%H.%M.%S).sql.tar.gz OpensimBackup.sql 
 +
 +
  #Lastly, we remove the uncompressed backup file. We no longer need that big file!
 +
rm OpensimBackup.sql
 +
 +
*Save the file, and give it a good name. For example, ''OpenSimBackup.sh''. I would suggest saving it directly to your homedirectory (~/OpenSimBackup.sh).
 +
*Next, we need to create a cron job. This can be done with one of the graphical tools that are available.
 +
**In GNOME, use ''gnome-schedule'' to set a scheduled job.
 +
**In KDE, use the Task Scheduler from your ''System Settings'' panel.
 +
 +
(Info needed about setting a cronjob from the terminal)
 +
 +
===Mac===
 +
<Example needed>
 +
 +
 +
 +
=PostgeSQL=
 +
I recently had to do a backup and restore of my PostgreSQL database.  Here, for the benefit of the other PostgreSQL user are my notes.  I did my backup and restore because I was updating the database software.
 +
* Shutdown OpenSim
 +
* Use the pg_dump command to backup the database.
 +
** In my case, I did this as the postgres user.  It should work as the OpenSim (or whatever user owns the OpenSim database) user.
 +
** pg_dump -b -Fc -C -f opensim.db.backup opensim
 +
** The -b option requests that large objects are included in the dump.  This would be things like textures and sounds.
 +
** The -Fc option creates the backup file as a gzipped tar file
 +
** The -C option includes commands to create the database when restoring
 +
** The -f option specifies the name of the output file.  In this case opensim.db.backup
 +
** There are a number of other options that can be used.  For example, if you're doing the backup on a different machine, the -h option allows you to specify the machine that the database is running on.
 +
* Copy the opensim.db.backup file to a CD-ROM or wherever you want it saved.
 +
* Do what you need to do.  In my case, it was upgrading the PostgreSQL software
 +
* While PostgreSQL was shutdown, I saved a tar of its /data directory to make it easier to recover if the upgrade went bad.
 +
* I also took copies of the configuration files in the /data directory so that I didn't have to recreate them.
 +
* Delete the /data directory
 +
* Initialize the new database
 +
** The command is initdb -D <path to /data directory>
 +
* Start the new PostgreSQL software (it will complain about data formats if you try this before you delete the old /data and run initdb)
 +
* Create the opensim user
 +
* Restore the data using pg_restore
 +
** pg_restore -C -d template1 opensim.db.backup
 +
** Read the PostgreSQL documentation for more information.
 +
In my case, it seemed to work fine.  After I started up OpenSim, I logged in and found everything as it should be.  I would really recommend trying this first on a test Sim that you didn't care about.  Also study the documentation before trying this.  Your setup may be different than mine.
 +
 +
 +
 +
=MS SQL=
 +
 +
<unknown>
 +
 +
[[Category:Database]]

Revision as of 19:52, 2 January 2011

Making backups of your configuration files and data is essential.

If necessary, you can also back up regions by using OpenSim Archives (OARs) and inventory using Inventory Archives. If you don't run your own grid, then this is a way to back up your data locally.


Contents

Local Files

The following files need to be saved:

  • Configuration files
    • OpenSim.ini
    • All files in config-include/
    • All region .xml or .ini files in Regions/
    • If you are running in grid mode, the various .xml configuration files. I using ROBUST Services a range of other .ini files for the various services must now also be backed up.

Feel free to add more if I've missed anything.


SQLite

Since SQLite saves its databases as local files, it's fairly simple to back it up.

  • Stop OpenSim
  • Copy all of the *.db files out of the /bin directory (assuming that you haven't changed this in the OpenSim.ini file) to wherever you want them saved.


MySQL

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 terminal 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!!!>

move %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>

Automatic Daily Backups

Windows

<Example needed>

Linux

This example is very Ububtu centered. Please add modifications for other distros, if/when needed.

In this example, we will assume that the username is admin, and the password is secret.

  • Open a text editor, and paste the following.
#!/bin/bash
  #Change to the folder where the files should be saved, for ease of use.
cd /home/Johnny/OpenSimBackups/

  #Make a backup of the opensim database
mysqldump -uadmin -psecret -r OpensimBackup.sql opensim

  #Tricky one! Compresses the backup file, and appends time and date.
  #This saves disk space, and lets you go back to an earlier date if needed.
tar -czf OpensimBackup_$(date +%Y-%m-%d-%H.%M.%S).sql.tar.gz OpensimBackup.sql  

  #Lastly, we remove the uncompressed backup file. We no longer need that big file!
rm OpensimBackup.sql
  • Save the file, and give it a good name. For example, OpenSimBackup.sh. I would suggest saving it directly to your homedirectory (~/OpenSimBackup.sh).
  • Next, we need to create a cron job. This can be done with one of the graphical tools that are available.
    • In GNOME, use gnome-schedule to set a scheduled job.
    • In KDE, use the Task Scheduler from your System Settings panel.

(Info needed about setting a cronjob from the terminal)

Mac

<Example needed>


PostgeSQL

I recently had to do a backup and restore of my PostgreSQL database. Here, for the benefit of the other PostgreSQL user are my notes. I did my backup and restore because I was updating the database software.

  • Shutdown OpenSim
  • Use the pg_dump command to backup the database.
    • In my case, I did this as the postgres user. It should work as the OpenSim (or whatever user owns the OpenSim database) user.
    • pg_dump -b -Fc -C -f opensim.db.backup opensim
    • The -b option requests that large objects are included in the dump. This would be things like textures and sounds.
    • The -Fc option creates the backup file as a gzipped tar file
    • The -C option includes commands to create the database when restoring
    • The -f option specifies the name of the output file. In this case opensim.db.backup
    • There are a number of other options that can be used. For example, if you're doing the backup on a different machine, the -h option allows you to specify the machine that the database is running on.
  • Copy the opensim.db.backup file to a CD-ROM or wherever you want it saved.
  • Do what you need to do. In my case, it was upgrading the PostgreSQL software
  • While PostgreSQL was shutdown, I saved a tar of its /data directory to make it easier to recover if the upgrade went bad.
  • I also took copies of the configuration files in the /data directory so that I didn't have to recreate them.
  • Delete the /data directory
  • Initialize the new database
    • The command is initdb -D <path to /data directory>
  • Start the new PostgreSQL software (it will complain about data formats if you try this before you delete the old /data and run initdb)
  • Create the opensim user
  • Restore the data using pg_restore
    • pg_restore -C -d template1 opensim.db.backup
    • Read the PostgreSQL documentation for more information.

In my case, it seemed to work fine. After I started up OpenSim, I logged in and found everything as it should be. I would really recommend trying this first on a test Sim that you didn't care about. Also study the documentation before trying this. Your setup may be different than mine.


MS SQL

<unknown>

Personal tools
General
About This Wiki