Backup Modifications.

2 views
Skip to first unread message

sytone

unread,
May 31, 2006, 6:52:33 AM5/31/06
to TiddlyWikiDev
Im not sure if I have used the correct approach for this plugin but it
works :)

I have created a plugin which changes the backup to use a cycle of
numbers:

file.1.html
file.2.html
.
.
file.x.html

Where x is a configrable item. you can get the plugin here.

http://sytone.com/tiddly/

Let me know if there are any isues with the way I hbave done this. As I
said it works well and can be configured.

Also is there a special us of the word systemTiddler, I have seen it
used but it is not referenced in the code anywhere.

Jeremy Ruston

unread,
May 31, 2006, 10:25:29 AM5/31/06
to Tiddly...@googlegroups.com
That's cool, Jon, thanks for sharing it. As to systemTiddlers - that
tag was used in an early versions of TW to indicate tiddlers that
would be copied to empty.html. Now that shadow tiddlers have been
introduced to solve that problem the mechanism is no longer required,
and I ought to remove the tag.

Cheers

Jeremy.


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

Jim Barr

unread,
May 31, 2006, 3:38:58 PM5/31/06
to TiddlyWikiDev
sytone,

Excellent idea!

I have just one observation:

When I repeatedly save my TiddlyWiki file, I get the following files:

file_1.html
file_2.html
file_3.html
file_4.html
file_5.html

So far so good. Next, I then save again, and it cycles back and
overwrites file_1.html. Again, this is expected. I then save again, and
it overwrites file_2.html. One more time, and it overwrites
file_3.html. Looking good!

OK, now, I exit my browser and restart it. I save the file and it
overwrites file_1.html, not file_4.html as I would expect. Is this
correct? It's really not a big deal as I DO have file dates to refer to
should I need them.

Otherwise, this is an EXCELLENT implementation!

-Jim Barr
http://TiddlyWikiTips.com

Saq Imtiaz

unread,
May 31, 2006, 5:26:56 PM5/31/06
to Tiddly...@googlegroups.com
On 5/31/06, sytone <jbu...@gmail.com> wrote:

Im not sure if I have used the correct approach for this plugin but it
works :)

I have created a plugin which changes the backup to use a cycle of
numbers:

file.1.html
file.2.html
.
.
file.x.html

Where x is a configrable item. you can get the plugin here.


I thought this had been done before? Or is there a difference that I am missing? :)
http://groups.google.com/group/TiddlyWiki/browse_thread/thread/1106178349fa688/d8e5d0d6be082ada?q=backup&rnum=1#d8e5d0d6be082ada

Scroll down the thread for the AlternateBackupPlugin.

Cheers,

Saq

PS: it also saves the current save file 'number' in a cookie so that if the file is reloaded, it starts overwriting the old files at the correct place. I modified my copy to automatically add the configuration options to the Advanced Options shadow tiddler.

sytone

unread,
May 31, 2006, 5:48:08 PM5/31/06
to TiddlyWikiDev
I looked to see if there was a plugin that did this and could not find
one!

Anyway Ill add the cookie save to my plugin (Thats what haoppens when
you do rapid dev :) )

I liked the suggestion in the thread about the time based backups.
Maybey ill expand :)

Thanks.

Saq Imtiaz

unread,
May 31, 2006, 5:51:14 PM5/31/06
to Tiddly...@googlegroups.com
On 5/31/06, sytone <jbu...@gmail.com> wrote:

I looked to see if there was a plugin that did this and could not find
one!

No worries, its hard to find plugins when they have only been posted to the group, but arent available in any TW's online anywhere. 

Anyway Ill add the cookie save to my plugin (Thats what haoppens when
you do rapid dev :) )

I'd also recommend adding  the configuration option to the AdvancedOptions shadow tiddler.

Cheers,
Saq

Daniel Baird

unread,
May 31, 2006, 7:52:37 PM5/31/06
to Tiddly...@googlegroups.com

You might be talking about a suggestion I made in that thread, where you have one backup each hour for the last 24 hours, then one per day for the last 7 days, etc.  I've had a couple of thoughts since then, so in case you *do* decide to implement something like this:

Firstly, I thought fewer levels would be simpler but still as good: hour, day, month is probably enough.  Every backup for current hour, one per hour for that day, one per day that month, and one per month forever.

Secondly, I realised that from an implementation point of view, it's easier to make the backup called backup-2006-06.html (ie June's backup) the state of your TW at the _first_ save in June, rather than the latest save in June; and the same for hour backups etc -- they should all be the first save in that time period.  That strategy avoids always having to replace backups with the latest one every time.

So, the save algorithm would be:

1 - get filenames for current month, day, and hour (eg "2006-06", "2006-06-01", and "2006-06-01-09")
2 - if there is no file at backups/(month).html:
        - save the current TW with that filename
        - create dir called backups/(month)-days
3 - if there is no file called (day).html in dir backups/(month)-days:
        - save the current TW with that filename
        - create dir called backups/(month)-days/(day)-hours
4 - if there is no file called (hour).html, in dir backups/(month)-days/(day)-hours
        - save the current TW with that filename
        - create dir called backups/(month)-days/(day)-hours/(hours)-all
5 - save a backup into backups/(month)-days/(day)-hours/(hours)-all
6 - finally, save the TW in it's normal position

..so the worst case is when you open your TW for the first time each month -- you get five saves and some directory operations, but normally you'd just get two saves, backup and live, which is what you have now.

If you had TW 2.1 you could store metadata telling you what the last backup was, so you wouldn't even have to check filenames each time.

Even though removing old backups is the main purpose of the whole thing, I've left that off this list, but basically you'd remove old dirs when you create the new ones.  Probably you'd want to keep the second most recent and delete the third most, or something.

Hopefully there are reliable, cross-browser file methods for doing all this :)

So that's where I got to, anyway.  Hope it helps someone..

;D

--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things That Suck)

sytone

unread,
May 31, 2006, 7:56:07 PM5/31/06
to TiddlyWikiDev
I looked at adding it to Advanced Options but for a cut and paste
Senario it may overwrite someone elses changes. I created a seperate
tiddler for the options.

For a idea is there the chance a systemOption tag be used to tag
tiddler that have options in them and they get added to the Advanced
Options tiddler on the fly.

That way any plugin can have its own options tiddler and it will be
added to the system for configuration.

Saq Imtiaz

unread,
Jun 1, 2006, 3:50:24 AM6/1/06
to Tiddly...@googlegroups.com
On 6/1/06, sytone <jbu...@gmail.com> wrote:

I looked at adding it to Advanced Options but for a cut and paste
Senario it may overwrite someone elses changes. I created a seperate
tiddler for the options.

config.shadowTiddlers.AdvancedOptions += "\n<<option chkBackupCountEnabled>> Enable the Cycle Function.\n
<<option txtBackupCount>> Set the number of files to save for backups.\n Current Save ID: <<BackupCycle>>";

Something like that will add the options to the AdvancedOptions shadow tiddler, and will not overwrite any user changes. The only issue with this is that if someone has modified the AdvancedOptions tiddler prior to installing your plugin, the options wont be added.
Still, it seems worth doing as there is nothing to loose.

For a idea is there the chance a systemOption tag be used to tag
tiddler that have options in them and they get added to the Advanced
Options tiddler on the fly.

That way any plugin can have its own options tiddler and it will be
added to the system for configuration.

There is no core support for this right now, but it can be implemented by the user....
for options tiddlers tagged with systemOption, using the forEachTiddler plugin. put this in the AdvancedOptions tiddler:

<<forEachTiddler
where
'tiddler.tags.contains("systemOptions")'
write
'"\n<<tiddler "+tiddler.title+"$))"'
>>

(not tested)


Saq

Saq Imtiaz

unread,
Jun 1, 2006, 4:22:28 AM6/1/06
to Tiddly...@googlegroups.com
On 6/1/06, Saq Imtiaz <lew...@gmail.com> wrote:


On 6/1/06, sytone < jbu...@gmail.com> wrote:

I looked at adding it to Advanced Options but for a cut and paste
Senario it may overwrite someone elses changes. I created a seperate
tiddler for the options.

config.shadowTiddlers.AdvancedOptions += "\n<<option chkBackupCountEnabled>> Enable the Cycle Function.\n
<<option txtBackupCount>> Set the number of files to save for backups.\n Current Save ID: <<BackupCycle>>";

Something like that will add the options to the AdvancedOptions shadow tiddler, and will not overwrite any user changes. The only issue with this is that if someone has modified the AdvancedOptions tiddler prior to installing your plugin, the options wont be added.
Still, it seems worth doing as there is nothing to loose.

Further update, here is what I am doing with the other backup plugin I posted, to add the option to the AdvancedOptions tiddler:

config.shadowTiddlers.AdvancedOptions += "\n MaxBackups: <<option txtMaxBackups>>";

if (store.getTiddler("AdvancedOptions"))
    {var optionTiddler = store.getTiddler("AdvancedOptions");
    if (optionTiddler.text.indexOf("txtMaxBackups")==-1)
          optionTiddler.set(null,optionTiddler.text+ "\n MaxBackups: <<option txtMaxBackups>>");}

I believe this covers all bases. Feel free to adapt for your plugin :)
Cheers,
Saq

PS: if adding more than one option, I'd recommend writing the above as a function that accepts the option as a parameter, rather than rewriting the code multiple times.

sytone

unread,
Jun 1, 2006, 6:43:28 AM6/1/06
to TiddlyWikiDev
Would it be a bit better written as such?

if (store.getTiddler("AdvancedOptions")) {
var optionTiddler = store.getTiddler("AdvancedOptions");
if (optionTiddler.text.indexOf("txtMaxBackups")==-1)
optionTiddler.set(null,optionTiddler.text+"\n MaxBackups:
<<option
txtMaxBackups>>");

} else {


config.shadowTiddlers.AdvancedOptions += "\n MaxBackups: <<option
txtMaxBackups>>";
}

Saves a unessary addition to AdvancedOptions

Saq Imtiaz

unread,
Jun 1, 2006, 8:34:49 AM6/1/06
to Tiddly...@googlegroups.com
On 6/1/06, sytone <jbu...@gmail.com> wrote:

The idea was to force the addition to the shadow tiddler at all times, and to the AdvancedOptions tiddler if it exists.
That way if at a later date the user deletes the AdvancedOptions tiddler, the shadow tiddler for it will still have the configuration option we added.


Cheers,
Saq
Reply all
Reply to author
Forward
0 new messages