http://opensimulator.org/index.php?title=Backup&feed=atom&action=historyBackup - Revision history2024-03-28T09:00:50ZRevision history for this page on the wikiMediaWiki 1.19.9http://opensimulator.org/index.php?title=Backup&diff=22503&oldid=prevMakopoppo: Redirecting to Backups2011-06-04T01:11:04Z<p>Redirecting to <a href="/wiki/Backups" title="Backups">Backups</a></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 01:11, 4 June 2011</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>#Redirect[[Backups]]</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>#Redirect[[Backups]]</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{delete|The contents in this page is merged into [[Backups#Automatic Daily Backups]]}}</del></div></td><td colspan="2"> </td></tr>
</table>Makopoppohttp://opensimulator.org/index.php?title=Backup&diff=20805&oldid=prevMakopoppo: Redirecting to Backups2011-01-03T03:22:59Z<p>Redirecting to <a href="/wiki/Backups" title="Backups">Backups</a></p>
<a href="http://opensimulator.org/index.php?title=Backup&diff=20805&oldid=19859">Show changes</a>Makopoppohttp://opensimulator.org/index.php?title=Backup&diff=19859&oldid=prevFritigern at 16:29, 19 November 20102010-11-19T16:29:11Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 16:29, 19 November 2010</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 166:</td>
<td colspan="2" class="diff-lineno">Line 166:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><font style="background-color: #f9f9f9" face="Courier New"></font></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><font style="background-color: #f9f9f9" face="Courier New"></font></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">[[Category:Database]]</ins></div></td></tr>
</table>Fritigernhttp://opensimulator.org/index.php?title=Backup&diff=16910&oldid=prevTedd: New page: = Backup of OpenSim MySQL database = == Linux == Add something like this to crontab for a weekly/daily/hourly run. (“crontab -e” to edit, “man crontab” to understand how to ...2010-03-05T11:46:05Z<p>New page: = Backup of OpenSim MySQL database = == Linux == Add something like this to crontab for a weekly/daily/hourly run. (“crontab -e” to edit, “man crontab” to understand how to ...</p>
<p><b>New page</b></p><div>= Backup of OpenSim MySQL&nbsp;database =<br />
<br />
== Linux ==<br />
<br />
Add something like this to crontab for a weekly/daily/hourly run. (“crontab -e” to edit, “man crontab” to understand how to edit)<br />
<pre>mysqldump -uuser -ppass dbname | gzip &gt; /tmp/mydb_`date +%Y%m%d_%H%M%S`.sql.gz</pre><br />
Crontab should e-mail you and errors in backup if it fails. (If your *nix is set up correctly)<br />
<br />
To verify the backup gunzip it and look inside the .sql-file, it should contain a DB-dump. For example by executing:<br />
<pre>zcat /tmp/mydb_YYYYMMDD_HHmmSS.sql.gz | more</pre><br />
To restore a given db:<br />
<pre>cat /tmp/mydb_YYYYMMDD_HHmmSS.sql.gz | gunzip | mysql -uuser -ppass dbname </pre><br />
== Windows ==<br />
<br />
The same as above can be done in Windows, but rotating the date can't be done in batch scripting afaik. I&nbsp;do however have a script for Windows I&nbsp;wrote for my OpenSim.<br />
<br />
This is a script for taking a full MySQL backup on Windows (all databases). It required ActiveState Perl and 7zip command line to work. ''It works equally well for Linux, but a few adjustments to paths in header needs to be made.''<br />
<br />
ActiveState Perl:&nbsp;[http://www.activestate.com/activeperl/ http://www.activestate.com/activeperl/]<br>7-Zip Command line: [http://www.7-zip.org/download.html http://www.7-zip.org/download.html]<br />
<pre>use strict;<br />
use locale;<br />
#<br />
# MySQL Backup Script by Tedd Hansen, tedd@konge.net, feb 2010<br />
#<br />
# THIS SCRIPT REQUIRES PERL INSTALLED. FOR WINDOWS USE ACTIVESTATE PERL.<br />
#<br />
# (1)<br />
# This script requires a backup-user to be created on the database.<br />
# Execute this: GRANT ALL on *.* to 'backup-user'@'localhost' identified by 'ZeBackup0perat00r'; <br />
<br />
#&nbsp;(change user and password at start of script))<br />
#<br />
# (2)<br />
# To schedule script in Windows you must create a user with log on locally rights like Administrator has.<br />
# DO NOT USE ADMINISTRATOR USER. If you do then backup will stop working next time we change password.<br />
# Set startup path to the location of script, and schedule script to execute every 5 hours for example.<br />
#<br />
<br />
<br />
# Where to put backup<br />
my $DIR_ROOT = "E:\\Backup";<br />
my $DIR_BACKUP = "$DIR_ROOT\\MySQL_Backup";<br />
<br />
# What to name backup<br />
# Note: !DB! will be replaced with database name, !DATE! with current date yyyyMMdd and !TIME! with current time HHmmss<br />
my $FILETEMPLATE = "MySQL !DB! !DATE! !TIME!.sqldump.7z";<br />
<br />
my $MYSQL_USER="backup-user";<br />
my $MYSQL_PASSWORD="ZeBackup0perat00r";<br />
my $MYSQL_HOST="localhost";<br />
<br />
# Full path to binary files we need<br />
my $BIN_7Z = "$DIR_ROOT\\7za.exe";<br />
my $BIN_MYSQLDUMP = "E:\\MySQL\\bin\\mysqldump.exe";<br />
my $BIN_MYSQL = "E:\\MySQL\\bin\\mysql.exe";<br />
my $CMD_LIST_DB = "echo show databases; | $BIN_MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST";<br />
<br />
# How long before we delete it?<br />
my $KEEP_HISTORY_FOR_DAYS = 30;<br />
<br />
# We are piping MySQLDump output directly into 7z for compression. 7z writes to filesystem.<br />
#<br />
# Note: !DB! and !OUTFILE! will be replaced with database name and filename for output file<br />
# -t7z = 7zip format<br />
# -mx5 = Medium compression: 0 = none , 9 = ultra .. Note: Increasing compression will use more CPU, and we want to reserve CPU for customers... :)<br />
# -ms = Create solid archive<br />
# -mmt = Multithreading<br />
# -mo=PPMd = PPMd algorithm (good for text, and we have only text)<br />
my $BACKUP_ARGS = "-u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST !DB! | $BIN_7Z a -y -t7z -mx7 -ms -mmt -si !OUTFILE!";<br />
<br />
#####################<br />
## START OF SCRIPT ##<br />
### ### <br />
my %DBDONE = {};<br />
<br />
# Attempt to create missing dirs<br />
mkdir "$DIR_ROOT" unless (-d $DIR_ROOT);<br />
mkdir "$DIR_BACKUP" unless (-d $DIR_BACKUP);<br />
<br />
# Check that we got all we need<br />
die "ERROR: ROOT DIR $DIR_ROOT DOES NOT EXIS!\n" unless (-d $DIR_ROOT);<br />
die "ERROR: BACKUP DIR $DIR_BACKUP DOES NOT EXIS!\n" unless (-d $DIR_BACKUP);<br />
die "ERROR: 7Z DOES NOT EXIST AT $BIN_7Z!\n" unless (-f $BIN_7Z);<br />
die "ERROR: MYSQLDUMP DOES NOT EXIST AT $BIN_MYSQLDUMP!\n" unless (-f $BIN_MYSQLDUMP);<br />
die "ERROR: MYSQLDUMP DOES NOT EXIST AT $BIN_MYSQL!\n" unless (-f $BIN_MYSQL);<br />
<br />
# Delete old backups<br />
print "Removing backups older than $KEEP_HISTORY_FOR_DAYS days.\n";<br />
CleanupOldies();<br />
<br />
# Make new backup<br />
print "Backing up all MySQL databases on $MYSQL_HOST...\n";<br />
open(DBLIST, "$CMD_LIST_DB |");<br />
while (my $dbname = &lt;DBLIST&gt;) {<br />
chomp $dbname;<br />
BackupDatabase($dbname);<br />
}<br />
close(DBLIST);<br />
<br />
sub CleanupOldies<br />
{<br />
# Get what time we should delete files at<br />
$KEEP_HISTORY_FOR_DAYS = 30 if ($KEEP_HISTORY_FOR_DAYS &lt; 1);<br />
<br />
my ($dsec,$dmin,$dhour,$dmday,$dmon,$dyear) = localtime(time - ($KEEP_HISTORY_FOR_DAYS * 24 * 60 * 60));<br />
my $DDATE = "0000".($dyear+1900).":00".($dmon+1).":00$dmday";<br />
my $DTIME = "00$dhour:00$dmin:00$dsec";<br />
$DDATE =~ s/^0*([^:]{4}):0*([^:]{2}):0*([^:]{2}).*/$1$2$3/;<br />
$DTIME =~ s/^0*([^:]{2}):0*([^:]{2}):0*([^:]{2}).*/$1$2$3/;<br />
my $CLEANTIME = $DDATE.$DTIME;<br />
<br />
opendir(BDIR, "$DIR_BACKUP");<br />
while (my $bfile = readdir(BDIR)) <br />
{<br />
# Does filename match?<br />
if ($bfile =~ m/(\d{8})\s+(\d{6})/) {<br />
my $bfiledate = $1.$2;<br />
# Is it old?<br />
if ($bfiledate &lt; $CLEANTIME) {<br />
print "Deleting old backup file: $bfile\n";<br />
unlink "$DIR_BACKUP\\$bfile";<br />
}<br />
}<br />
}<br />
closedir(BDIR);<br />
}<br />
<br />
sub BackupDatabase<br />
{<br />
my $dbname = shift;<br />
<br />
# Only process each DB once<br />
return if ($DBDONE{lc($dbname)});<br />
$DBDONE{lc($dbname)} = 1;<br />
<br />
# Get current date<br />
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);<br />
my $DATE = "0000".($year+1900).":00".($mon+1).":00$mday";<br />
my $TIME = "00$hour:00$min:00$sec";<br />
$DATE =~ s/^0*([^:]{4}):0*([^:]{2}):0*([^:]{2}).*/$1$2$3/;<br />
$TIME =~ s/^0*([^:]{2}):0*([^:]{2}):0*([^:]{2}).*/$1$2$3/;<br />
<br />
# Get output filename<br />
my ($backup_filename) = $FILETEMPLATE;<br />
$backup_filename =~ s/!DB!/$dbname/i;<br />
$backup_filename =~ s/!DATE!/$DATE/i;<br />
$backup_filename =~ s/!TIME!/$TIME/i;<br />
my ($backupfile) = "$DIR_BACKUP\\$backup_filename";<br />
<br />
# Get output command<br />
my ($cmd_mysqldump) = "$BIN_MYSQLDUMP $BACKUP_ARGS";<br />
$cmd_mysqldump =~ s/!DB!/$dbname/i;<br />
$cmd_mysqldump =~ s/!OUTFILE!/\"$backupfile\"/i;<br />
<br />
#<br />
# Make backup...<br />
#<br />
print "* Backing up database '$dbname'\nTo file: $backupfile\n";<br />
print `$cmd_mysqldump`;<br />
my ($dsec,$dmin,$dhour,$dmday)=localtime(time);<br />
my $doneTime = "00".($dmday - $mday).":00".($dhour - $hour).":00".($dmin - $min).":00".($dsec - $sec);<br />
$doneTime =~ s/^0*([^:]{2}):0*([^:]{2}):0*([^:]{2}):0*([^:]{2}).*/$1d $2:$3:$4/;<br />
print "Backup of $dbname done in $doneTime.\n\n";<br />
<br />
}<br />
</pre><br />
<font style="background-color: #f9f9f9" face="Courier New"></font></div>Tedd