• Uploaded By: maroon
  • Added: 3 years ago
  • Updated: 3 years ago
  • mIRC Version: used 6.35 & 7.52+
  • Hits: 1,686
  • Size: 10.11KB
  • Downloads: 38
  • Review By: entropy

mirc.ini Backup v1.1

Defend against your mIRC configuration settings being trashed because windows crashes while writing to mirc.ini
Saves mirc.ini to a backup named after the day of the week, at 2 hours intervals.
If your mirc.ini does get reset to defaults, you can quit mirc.exe then copy one of the backups on top of the mirc.ini being used.

  1    0  Login to Vote.

Source Code:
  1. /* {
  2. mIRCiniBackup v1.1 by maroon. Saves backup of mirc.ini at 2 hours intervals!
  4. Syntax: /mIRCiniBackup [now] [duration string | hours ]
  6. If you wish to accept the default 2 hours, there's nothing to do except install this script, then wait for mirc.ini to get trashed. Otherwise:
  8. /mIRCiniBackup now
  9. ... forces script to backup mirc.ini now, even if it's not yet time.
  11. /mIRCiniBackup 90 min
  12. /mIRCiniBackup 1.5 hr
  13. /mIRCiniBackup 1 hr 30 min
  14. /mIRCiniBackup 3
  15. ... any string accepted as a parameter in $duration(string) overrides the default 2 hour interval, except any number-only
  16. is hours, and it only accepts intervals as large as 24 hours. This resets the timer to be that distance into the future,
  17. but doesn't trigger a backup unless the backup is changed to an interval already past due according to the time of the
  18. most recent backup. To also force the backup now, insert the 'now' parameter: /mIRCiniBackup now 90 min
  20. If mirc.ini is damaged, it gets reset to default, and no longer contains a list of loaded scripts, which means this script
  21. won't be loaded where it could backup a damaged mirc.ini on top of a 'good' one. You can restore settings and scripts by:
  23. 1. Quit mirc.exe
  24. 2. Copy one of the 7 daily backup files on top of the mirc.ini being used by mIRC. These backups are in same folder where mirc.ini is.
  25. 3. Just to be safe, copy these 7 files somewhere safe, until you've fixed your problem.
  26. 4. restart mirc.exe to see if you chose the best backup.
  28. The reason to copy your 7 daily backups somewhere safe is that if you restore a backup mirc.ini that contains this script
  29. file as one of the loaded scripts, it will immediately copy that mirc.ini on top of the backup named after today's date,
  30. which you may not want to happen. The backups will have a timestamp from when the backup was made, not when the last
  31. configuration change was made.
  33. Even though mIRC has taken steps to avoid the problem, I've continued to see reports of people losing their settings in a
  34. crash. mirc.ini can become damaged if Windows crashes while mIRC is shutting down, or at other times when mIRC is busy writing
  35. to mirc.ini. When that happens, mirc.ini can become a zero byte file, so mIRC replaces mirc.ini with a default copy, and all
  36. your configuration changes are gone. The chances of your scripts also being lost is very low since mIRC isn't writing to
  37. script files very often. One of the effects of mirc.ini being reset to default is that your mirc.ini no longer contains a list
  38. of loaded scripts. However your scripts are almost certainly where they belong and undamaged. If you can quit mIRC then copy
  39. a recent backup of mirc.ini to the path\filename where mirc.exe is looking for mirc.ini, you should be fine, except for not
  40. having changed settings made within the recent few hours after the last backup.
  42. By saving backups to 7 different files, this script eliminates the chance that mIRC crashes during the backup and ruins the
  43. only backup and the original at the same time. It also gives you the chance to restore settings to the way they were in
  44. previous days, or you can edit the script to make monthly backups too.
  46. The semicolon'ed lines show how to backup other files if you wish to backup them too. The other files usually don't get
  47. trashed during a crash the way mirc.ini can, so I didn't enable backup of those files too.
  49. In addition to saving backups named after the days of the week, you can remove a semi-colon to activate a line which saves a
  50. backup of mirc.ini to the name of the current month, which helps for configuration changes that you may not be aware of for
  51. longer periods of time, such as minor changes to your color settings. This would eventually cause the backup to display copying
  52. 12+7=19 files, so you can change "copy" to ".copy" to suppress the display - or you can delete very old monthly backups.
  54. Even though the default interval is 2 hrs, the script often displays a message that the next backup will execute 1 second
  55. shorter than the interval. That's because of the way $timer().secs reports.
  57. //timertest 1 10 noop | echo -a $timer(test).secs
  58. ... usually reports 9 instead of 10. mIRC takes the number of milliseconds, then divides by 1000 and drops the fraction.
  60. Changelog: v1.1 added control.ini as an optional file to be backedup.
  61. }
  62. */
  64. ; if you wish the interval to be a different number of hours instead of 2 hours, edit the '2' in the START event.
  65. ; It takes effect next time you start mIRC, or you can paste the new command in the editbox like: /mIRCiniBackup 3 hours
  66. ON *:START:{ mIRCiniBackup 2 hours }
  68. alias mIRCiniBackup {
  69. var %mIRCiniBackup.interval 3600 * 2
  70. var %now 0 , %new.interval %mIRCiniBackup.interval , %delay $timer(mIRCiniBackup).delay , %sc $chr(3) $+ 0, $+ $color(notice)
  71. if (($timer(mIRCiniBackup)) && (%delay)) var %mIRCiniBackup.interval %delay
  72. if ($1 == now) { inc %now | tokenize 32 $2- }
  73. if ($duration($1-) isnum 1-86400) var %new.interval $v1
  74. elseif ($1 isnum 0-24) var %new.interval $1 * 3600
  75. elseif ((%delay) && (%delay != %new.interval)) var %new.interval %delay
  76. if (($ctimer) && ($ctimer != mIRCiniBackup) && ($timer(mIRCiniBackup))) { echo -sgc info * mIRCiniBackup: won't run from duplicate timer $ctimer | return }
  77. echo -sg %sc =/=/=/=/=/=/= mIRCiniBackup by maroon $+ $chr(169) v1.1 backs up mirc.ini at $duration(%mIRCiniBackup.interval) intervals! $chr(3)
  78. if ((($script(0)) && ($calc($ctime +1- %mIRCiniBackup.NewestBackup) >= %mIRCiniBackup.interval)) || (%now)) {
  79. ; saveini forces pending changes to be written to disk, to avoid being lost in a crash
  80. saveini
  81. echo -sg $+($chr(3),8,$chr(44),12) Backups being done NOW! $chr(3)
  82. var %dow $calc($calc(1+($int($calc(($ctime($date 12:00) - $ctime(4/1/1970 00:00)) /86400)) % 7))) , %weekday $asctime($ctime,dddd) , %month $asctime($ctime,mm_mmmm)
  84. var %file $mircini | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  86. ; removing semi-colon from the lines in the next group which begin with "; var" activates those commands instead of being comments
  87. ; To suppress the display of the COPY commands in this script, change copy to .copy
  89. ; make 12 extra monthly backups of mirc.ini named after the months.
  90. ; var %file $mircini | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%month,.bak))
  91. ; next lines show examples of backing up other key configuration files. They're commented because it's rarely needed compared to mirc.ini
  92. ; Right-click menus for nicklist, channel, status. default filename = popups.ini
  93. ; var %file $readini($mircini,pfiles,n0) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  94. ; list of servers in ALt+E window. default filename = servers.ini
  95. ; var %file $readini($mircini,files,servers) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  96. ; users tab of Alt+R editor. default filename = users.ini
  97. ; var %file $readini($mircini,rfiles,n0) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  98. ; variables tab of Alt+R editor. default filename = vars.ini
  99. ; var %file $readini($mircini,rfiles,n1) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  100. ; commands for OPTIONS/connect/options/perform. Filename is always perform.ini
  101. ; var %file perform.ini | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  102. ; Alt+U 'url catcher' default filename = urls.ini
  103. ; var %file $readini($mircini,files,urls) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  104. ; Users tab of Address-Book. default filename = addrbk.ini
  105. ; var %file $readini($mircini,files,addrbk) | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  106. ; Control tab of Address-Book. Filename is always control.ini
  107. ; var %file control.ini | if ($file(%file).size) copy -o $qt(%file) $qt($+($remove($nofile(%file),$mircdir),$nopath(%file),_,%dow,_,%weekday,.bak))
  109. inc %now | set %mIRCiniBackup.PrevBackup %mIRCiniBackup.NewestBackup | set %mIRCiniBackup.NewestBackup $ctime
  110. }
  111. if ((%now) || (%new.interval != %mIRCiniBackup.interval) || (!$timer(mIRCiniBackup))) .timermIRCiniBackup -oi 0 %new.interval mIRCiniBackup $calc(%new.interval /3600)
  112. echo -sgc info mirc.ini backups at $duration(%mIRCiniBackup.interval) intervals. $iif(%mIRCiniBackup.interval != %new.interval,Overridden to $duration(%new.interval) *) $iif(%mIRCiniBackup.NewestBackup , Newest Backup $duration($calc($ctime - %mIRCiniBackup.NewestBackup)) ago $iif(%mIRCiniBackup.PrevBackup,* Backup before that $duration($calc($ctime - %mIRCiniBackup.PrevBackup)) ago))
  113. echo -sgc info To restore: 1. Quit mIRC 2. copy one of these $findfile($mircdir,$+($nopath($mircini),_*.bak),0,1,echo -sg $asctime($file($1-).mtime) $chr(22) $1- $chr(22) $iif($asctime($file($1-).mtime,mm.dd.yyyy) == $asctime($ctime,mm.dd.yyyy),*today)) backups on top of $mircini 3. Copy all somewhere safe 4. Restart mIRC
  114. echo -sg %sc =/=/=/=/=/=/= Next Backup scheduled in $duration($timer(mIRCiniBackup).secs) @ $time($calc($ctime + $timer(mIRCiniBackup).secs)) * Force too-soon backup now and change interval: /mIRCiniBackup now 4 hours $chr(3)
  115. if (($ctimer == mIRCiniBackup) || ($ctimer == $null)) return
  116. var %i $timer(0) | while (%i) { if ($timer(%i) == $ctimer) { timer $+ %i off | return } | dec %i }
  117. }
  118. on *:unload:{ unset %mIRCiniBackup.* | timermIRCiniBackup off | echo -sgc info $nopath($script) unloaded. Thanks for trying it out. }

No Comments.

Login to Comment.