Random Access Memories

June 15, 2011

The “Lasivian wants an automatic Opensim backup” project.

by @ 1:45 am. Filed under Personal, Secondlife, Server Admin, Technology

It’s sloppy, but most importantly it works, and it backs up EVERYTHING. Terrain maps, world map image, .oar, .xml, all three .ini files, mysql database, etc.

I based this off the backup script here:

  • http://opensimulator.org/wiki/Backing_Up_LINUX
  • I’m running Ubuntu 11.04 server, x64 btw and this all works.

    I store both scripts in /home/username/backupdir/scripts, the shell script gets run as a cron job.

    #!/bin/sh
    ;Not that it *really* matter that we tell people, but I think it's polite, heh.
    screen -S opensim -p 0 -X eval 'stuff "alert Beginning full simulator backup, things might be slow for a bit.^M"'
    ;Yes, I'm redundant, this is just in case I missed something
    cd /home/username/backupdir
    ;Copy the old backups to a holding directory, I clean them out by hand every so often. This could be an offsite location.
    mv /home/username/backupdir/*.* /home/username/backupdir/old
    ;This line runs the second command script inside the opensim process.
    screen -S opensim -p 0 -X eval 'stuff "command-script /home/username/backupdir/scripts/osbackup.txt^M"'
    ;Now dump the mysql data to zip and date it.
    mysqldump -ulogin -ppassword opensim | gzip > /home/username/backupdir/opensimbackup_`date +%Y%m%d_%H%M%S`.sql.gz
    ;Copy and date the 3 .ini files
    cp /home/username/opensim/bin/OpenSim.ini /home/username/backupdir/opensim_`date +%Y%m%d_%H%M%S`.ini
    cp /home/username/opensim/bin/Regions/Regions.ini /home/username/backupdir/regions_`date +%Y%m%d_%H%M%S`.ini
    cp /home/username/opensim/bin/config-include/StandaloneCommon.ini /home/username/backupdir/standalonecommon_`date +%Y%m%d_%H%M%S`.ini
    ;The next line is just a delay so the .oar output can finish, it might take your server much longer, change as needed.
    sleep 30
    ;There is likely a much more efficient way to do the following, but this was what I could figure out
    timestamp=$(date)
    ;these rename the opensim dumped files to add timestamps to the names. I think this makes them easier to manage later.
    for f in epsilon.*
    do mv "$f" "epsilon_$timestamp.${f#epsilon.}"
    done
    for f in techrealms.*
    do mv "$f" "techrealms_$timestamp.${f#techrealms.}"
    done
    for f in theta.*
    do mv "$f" "theta_$timestamp.${f#theta.}"
    done
    for f in delta.*
    do mv "$f" "delta_$timestamp.${f#delta.}"
    done
    for f in connections.*
    do mv "$f" "connections_$timestamp.${f#connections.}"
    done
    ; Guessing this could also probably inform something in-world that could record backups. I'm not sure how tho
    screen -S opensim -p 0 -X eval 'stuff "alert Backup complete, thank you.^M"'

    This second script is executed inside the screen that is running opensim.

    ;Script Name = osbackup.txt
    ;executed with "command-script /home/username/backupdir/scripts/osbackup.txt" inside opensim
    ;
    change region root
    ; Persist objects to the database now
    backup
    ;
    change region techrealms
    ; export world map image
    export-map /home/username/backupdir/techrealms.jpg
    ; save terrain
    terrain save /home/username/backupdir/techrealms.r32
    ; save prims to XML
    save xml2 /home/username/backupdir/techrealms.xml
    ; save the current region to an opensim archive
    save oar /home/username/backupdir/techrealms.oar
    ;
    ; repeat as needed
    ;
    change region delta
    export-map /home/username/backupdir/delta.jpg
    terrain save /home/username/backupdir/delta.r32
    save xml2 /home/username/backupdir/delta.xml
    save oar /home/username/backupdir/delta.oar
    ;
    change region theta
    export-map /home/username/backupdir/theta.jpg
    terrain save /home/username/backupdir/theta.r32
    save xml2 /home/username/backupdir/theta.xml
    save oar /home/username/backupdir/theta.oar
    ;
    change region epsilon
    export-map /home/username/backupdir/epsilon.jpg
    terrain save /home/username/backupdir/epsilon.r32
    save xml2 /home/username/backupdir/epsilon.xml
    save oar /home/username/backupdir/epsilon.oar
    ;
    change region connections
    export-map /home/username/backupdir/connections.jpg
    terrain save /home/username/backupdir/connections.r32
    save xml2 /home/username/backupdir/connections.xml
    save oar /home/username/backupdir/connections.oar

    Use them however you want. If someone wants to clean them up for me that would be appreciated.

    Thanks & good luck.

    Lasivian's small corner of the web.
    (Please wipe your browser before entering so you don't track in mud)

    Internal Pages:

    Categories:


    Misc:

    Si hoc legere scis mimium eruditionis habes

    Does your brain hurt yet?

    retesostft vntphoim enuni toegtieittyft nece n tiog siheun sec eevd go doyvweelprnnstt ievtg h i tieosddfrntea ytiedtt uryrieyhmhsug rer hieoywle unie tnxeref nfls ettdsiedte fnsiei fdhfZ

    (I can't remember how I encrypted this cipher , the first person to crack it gets 10$ via Paypal.)

    My Email:

    01001010011101010111001101110 10000100000011010000110100101 10010001101001011011100110011 10010000001101101011110010010 00000110010101101101011000010 11010010110110000100000011010 01011011100010000001110000011 01100011000010110100101101110 00100000011100110110100101100 11101101000011101000000110100 00101000001101000010100100110 00110000101110011011010010111 01100110100101100001011011100 10000000110011101101101011000 01011010010110110000101110011 000110110111101101101
    WTF?

    How long the USA has been under corporate rule:

    Search Posts:

    Archives:

    November 2024
    S M T W T F S
     12
    3456789
    10111213141516
    17181920212223
    24252627282930

    External Links:

    Things i've read lately:

    QR Codes

    (Scan these on your cellphone)

    My website URL

    My E-mail

    other:

    38 queries. 0.057 seconds