Tiddlywiki on Node.js: Backup

294 views
Skip to first unread message

Mohammad

unread,
Mar 30, 2019, 1:25:49 AM3/30/19
to TiddlyWiki
This may be a redundant question:
 Working with Tiddlywiki on Node.js, on every change a Saving action is triggered, but the modified tiddler is overwrite!
As I used to work with Tiddlydesktop and Timimi, I can create backups or save on demand!

is there any way to have backup or save on demand when working on Node.js?

--Mohammad

RA

unread,
Mar 31, 2019, 12:55:19 PM3/31/19
to TiddlyWiki
I use syncthing to propagate my wiki folder from server to 2 workstations. It comes with file versioning functionality. I'm not familiar with Tiddlydesktop not Timimi, but I'm guessing that's what you are looking for?

Mohammad

unread,
Mar 31, 2019, 1:04:16 PM3/31/19
to TiddlyWiki
Hi RA,
 Actually I am using TW on Node.js on a Windows machine and I like to have a backup of the tiddlers I change!

--Mohammad

Mohammad

unread,
Apr 3, 2019, 8:49:00 AM4/3/19
to TiddlyWiki
Hi again RA,

I found Synkron (http://synkron.sourceforge.net/) to create backup!
It also support file version system!
It is portable, work on local machine and support different OS!

--Mohammad

p.s

PMario

unread,
Apr 4, 2019, 10:39:11 AM4/4/19
to TiddlyWiki
On Sunday, March 31, 2019 at 7:04:16 PM UTC+2, Mohammad wrote:
 Actually I am using TW on Node.js on a Windows machine and I like to have a backup of the tiddlers I change!

Windows 10 has a built in file history function, which is disabled by default. ... The only thing you need is a "spare" drive, and use it as the System Backup drive.

See:

 
I did a short test configuring it, which works. ... But I'd need to test it over a longer period, to see how it works out.

have fun!
mario

Mohammad

unread,
Apr 4, 2019, 11:31:16 AM4/4/19
to TiddlyWiki
Many thanks Mario!
I will have a look and inform you how it works for me!

--Mohammad

PMario

unread,
Apr 4, 2019, 11:51:57 AM4/4/19
to TiddlyWiki
On Thursday, April 4, 2019 at 5:31:16 PM UTC+2, Mohammad wrote:
Many thanks Mario!
I will have a look and inform you how it works for me!

I did a little bit more testing.

 - The minimum "backup period" is 10 minutes.
 - Triggering a manual "Backup run" is not trivial, since the setting is "hidden well" in the config dialogues.
 - The initial setup contains a lot of "useless default settings / directories".
    - So I needed to disable them 1 by 1, which is annoying.
    - I did test with a 10GByte virtual drive. The default filled it about 50% :/
    - The good thing is. Drive E: is accessible with the file explorer and can delete that stuff
 - I did set the whole drive E: to be compressed, which should give a lot more space, since tiddlers can be compressed very well

Just some thoughts.

-mario

Mohammad

unread,
Apr 4, 2019, 11:59:46 AM4/4/19
to TiddlyWiki
Thanks Mario for these valuable information!

--Mohammad

Mark S.

unread,
Apr 4, 2019, 12:59:08 PM4/4/19
to TiddlyWiki
Tiddlyserver has a built-in backup, though I'm not sure how it works with data folders.

-- Mark

TonyM

unread,
Apr 4, 2019, 7:59:38 PM4/4/19
to TiddlyWiki
Mohammand,

For your exploration.

On Windows 10, 
  • I sometimes simply zip a whole wikifolder for backup before a major event. This could be automated if desired.
  • If the folder was connected to a Dropbox (or version controled sync) sync, dropbox would maintain multiple versions of each file.
  • A Button to export recently changed or the whole wiki to a file would be a way to backup a folder based wiki to file.
    • There is a lot of room here for new solutions and worth exploring.
    • This button could be triggered in startup actions to backup on load, or with a close wiki button.
  • The official plugin Auto-download modified tiddlers, in effect allows a "transaction log"

This plugin causes TiddlyWiki to continuously download (as a JSON file) the contents of any tiddler that is manually changed by any of several means:

  • Confirming an edit
  • Deleting tiddlers
  • Imports
  • Renames/relinks
  • Optionally, typing in draft tiddlers can trigger a download

Where appropriate, separate 'before' and 'after' files are downloaded. Configured correctly, the browser will download the files silently in the background, and they can be used as a backup in case of accidental data loss.

Mohammad

unread,
Apr 5, 2019, 1:15:50 AM4/5/19
to TiddlyWiki


On Friday, April 5, 2019 at 4:29:38 AM UTC+4:30, TonyM wrote:
Mohammand,

For your exploration.

On Windows 10, 
  • I sometimes simply zip a whole wikifolder for backup before a major event. This could be automated if desired.
I started using Sunkron. It supports multi platforms and lets a simple version control! I tried for Windows 10 backup and vcs, but as Mario explained it is not that userfriently!
  • If the folder was connected to a Dropbox (or version controled sync) sync, dropbox would maintain multiple versions of each file.
  • A Button to export recently changed or the whole wiki to a file would be a way to backup a folder based wiki to file.
    • There is a lot of room here for new solutions and worth exploring.
    • This button could be triggered in startup actions to backup on load, or with a close wiki button.
This could be promising! 

MidnightLightning

unread,
Apr 5, 2019, 9:45:57 AM4/5/19
to TiddlyWiki
I use git to track changes to my tiddlers, which is a more common developer workflow, but definitely do-able for non-developers as well. Using git to track your wiki changes is mentioned in the TiddlyWiki documentation as a means to create documentation for other projects, and developing plugins for TiddlyWiki, though just tracking changes to your own tiddlers works well too.

Mohammad

unread,
Apr 5, 2019, 10:33:53 AM4/5/19
to TiddlyWiki
Thanks MidnightLightning !

I will have a look, specially now I am experimenting with Node.js version of TW and GitHub!
Of course I use GitHub Desktop version!

--Mohammad

Mohammad

unread,
Apr 6, 2019, 4:22:46 PM4/6/19
to tiddl...@googlegroups.com
Good to share! If you work on Windows the below batch file can be used to create
backups from you Tiddlywiki files using robocopy!

save this in a .bat or .cmd file like mybackup.cmd
set the source and destination folders as you liken, and it works!

I used for example 

source=G:\TW\TW-Yazd
dest =G:\TW\MyArchive\TW-Yazd 


@echo off
cls

:: Set Source folder, from which you copy files/folders
set source=G:\TW\TW-Yazd
:: Set Destination folder, from which you copy files/folders
set dest=G:\TW\MyArchive\TW-Yazd
:: Set Archive folder (keeps zipped files) 
set archive=%dest%\backups

:: Sets specific copy instructions
:: See readme for more details
SET what=/COPY:DT /E


:: See readme for more details
:: Log file specifications
SET _options=/LOG:%dest%\backup.log


:: Generate a yyyy.mm.dd-hh.mm.ss extension
set _dateExt=%date:~-4,4%.%date:~-7,2%.%date:~-10,2%-%time:~0,2%.%time:~3,2%.%time:~6,2%
:: add leading zeros
set _dateExt=%_dateExt: =0%

:: Starts ROBOCOPY
ROBOCOPY "%source%" "%dest%\%_dateExt%" %what% %_options%

:: zips up the backup folder
"C:\Program Files\7-Zip\7z.exe" a -t7z  "%archive%\%_dateExt%.7z" "%source%\*" -r > null

::REF


You can turn off zip or plane backup or keep both of them as I used above!
Note: for zip, it uses 7zip if you have other programs replace the below line

"C:\Program Files\7-Zip\7z.exe"


--Mohammad

TonyM

unread,
Apr 7, 2019, 12:12:36 AM4/7/19
to TiddlyWiki
Something I discovered for exporting batch files

  • Place the batchfile in a tiddler of the type text/plain
  • In windows install a printer of the Generic / Text Only type
  • In Properties/Ports select file: to print to file
Now when you come across your batch file tiddler 
  • Optional copy the filename of the batch file to the clipboard
  • Open the tiddler in a New window
  • Select Print
  • Select Generic / Text Only Printer
  • The save file dialogue opens, paste or type the filename eg test.bat test.cmd
  • Ok to save the file - the HTML extension will not be added and it is a valid batch file ready to run.
Regards
Tony

On Sunday, April 7, 2019 at 6:22:46 AM UTC+10, Mohammad wrote:
Good to share! If you work on Windows the below batch file can be used to create
backups from you Tiddlywiki files using robocopy!

save this is .bat or .cmd file like mybackup.cmd
set the source and destination folder and it works!

Mohammad

unread,
Apr 7, 2019, 12:55:59 AM4/7/19
to TiddlyWiki
Thanks Tony for suggestion!
I am still thinking if a button can run the batch file in the background and make the backup!

--Mohammad

Mohammad

unread,
Apr 7, 2019, 6:05:05 PM4/7/19
to TiddlyWiki
may be useful!

The below code is a Windows batch file to create a backup of your Tiddlywiki files.
This is useful specially when you work with Node.js version Tiddlywiki which have a lot of tiddlers.

The script:
  1. always create an identical copy of source tiddlers
  2. create version-incremented copies of all files differ from their source (you may change a tiddler in source or backup folder)
  3. version number started from 000 ~ 999, so this is maximum number of versions
  4. use robocopy which is very fast method for creating backups

How to use
  1. Change the source and destination folders to meet your case
  2. run the batch file

file: vc-backup.cmd

:: Running the script will first Robocopy any files which don't already exist in the destination,
:: then use xcopy to create version-incremented copies of any files which do exist in the destination.
:: Mohammad Rahmani

:: Rev 0.9
:: Apr 8th, 2019

@echo off
cls

 
:: Source and destination paths.  Do not include a trailing backslash
set SourceFolder="G:\Test-Robocopy\my source"
set DestinationFolder="G:\Test-Robocopy\my dest"
 
 
 
 :: -----------------------------------------------------------------------------------------------------
 
 :: Remove double and single qoutes if any
 set source=%SourceFolder:"=%
 set source=%source:'=%
 set dest=%DestinationFolder:"=%
 set dest=%dest:'=%
 
 setlocal EnableDelayedExpansion
 :: Copy any file, folder not existed in the destination
robocopy "%source%" "%dest%" /XC /XN /XO /R:3 /W:3 /E /XX 
 
:: List all files existed in destination, but there is a difference between each file and its 
:: source
for /F "tokens=*" %%G in ('robocopy "%source%" "%dest%" /XX /L /NDL /NS /NC /NJH /NJS /E') do (
 call :_process "%%G"
)
goto :eof
 
:: The process subroutine here does the below tasks
:: a. create a new copy of destination file prefixed with _vxxx, where xxx: 001 ~ 999 (version-incremented copies )
:: so this only keep 1000 revisions and cannot work for more revisions
:: b. copy the source file and overwrite the destination. So, destination is always equal to source
:_process
set counter=0
set version=000
set source_path=%~dp1
set file=%~n1
set ext=%~x1
 
:: Create the destionation path for the existed file. by replacing the
:: source path with destination path. (search and replace)
set dest_path=!source_path:%source%=%dest%!


:: Check to see what is the last version number to create the next version number 
:_loop
if exist "%dest_path%%file%_v%version%%ext%" (
 set /A counter+=1
 :: create a number with leading zeros like 001 ~ 999
 set version=000!counter!
 set version=!version:~-3!
 goto :_loop
)

:: Increment the version number of the file in destination  which differes from its identical one in source
echo F|xcopy "%dest_path%%file%%ext%" "%dest_path%%file%_v%version%%ext%" /C /H /R /Z  /Q
:: Copy from source and overwrite the respective file in destination:  source = destination
echo F|xcopy %1 "%dest_path%\%file%%ext%" /C /H /R /Z /Y /Q
goto :eof

endlocal



Reply all
Reply to author
Forward
0 new messages