[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Automatically back up your world files

Automatically back up your world files

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Nick Gammon   Australia  (23,042 posts)  [Biography] bio   Forum Administrator
Date Tue 07 Sep 2010 11:55 PM (UTC)

Amended on Wed 08 Sep 2010 12:10 AM (UTC) by Nick Gammon

Message
The plugin below automatically backups up your world file to a new name every day. It does it on a connect, and a disconnect. The name used is the existing file name, with the date added, eg.


C:\Program Files\MUSHclient\worlds\SmaugFUSS-backup-08-Sep-2010.MCL


Since the file name has just the day/month/year in it, you will only get one file per day. This saves your disk filling up with thousands of files. And if something goes wrong, the most recent backup would be only a day old.

Template:saveplugin=Automatic_Backup To save and install the Automatic_Backup plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Automatic_Backup.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Automatic_Backup.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Automatic_Backup"
   author="Nick Gammon"
   id="bb6a05ed7534b5db1ed40511"
   language="Lua"
   purpose="Backs up the world file to a new name each day"
   date_written="2010-09-08 09:38:17"
   requires="4.40"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Install to backup your world file to a file of the same name with the day/month/year added to it.
]]>
</description>

</plugin>

<script>
<![CDATA[

function do_backup ()
  -- find name of world file
  local world_file_name = GetInfo (54) 
  
  -- if found (ie. not just newly created) back it up
  if world_file_name and world_file_name ~= "" then
    -- strip out .MCL (or .mcl), add the date, and put .MCL back
    world_file_with_date = string.gsub (world_file_name, "%.[Mm][Cc][Ll]$", "") .. 
                           os.date ("-backup-%d-%b-%Y.MCL")
                           
    -- save if possible                           
    if (Save (world_file_with_date, true) == false) then
      ColourNote ("orange","", "World file backed up as " .. world_file_with_date)
    else
      ColourNote ("red", "", "Could not back up world file.")
    end -- if
  
  end -- if world file name known

end -- do_backup

-- back when first connecting
function OnPluginConnect ()
  do_backup ()
end  -- OnPluginConnect

-- back up when disconnecting (eg. after improving it)
function OnPluginDisconnect ()
  do_backup ()
end -- OnPluginDisconnect

]]>
</script> 

</muclient>


This plugin will be supplied with MUSHclient version 4.61 onwards.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,133 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]