mIRC Home    About    Download    Register    News    Help

Print Thread
#162206 15/10/06 10:33 AM
Joined: Oct 2003
Posts: 68
Y
yamaz Offline OP
Babel fish
OP Offline
Babel fish
Y
Joined: Oct 2003
Posts: 68
Hi, I need a simple script that can make the following things:

- back up certain files of my choice (e.g. mirc.ini, system.ini and stuff) with a "/backup" command in a selected directory
- schedule auto-backups (daily, weekly... user choice)
- tell the user when the last backup was made


any help?

#162207 15/10/06 02:50 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here:

Code:
alias backup {
  if ($1 == $time) { echo -a $date(%backup.date,hh:nn:sstt - mm/dd/yyyy)  | return }
  if ($1 == daily) { .timerbackup 0 86400 backup }
  if ($1 == weekly) { .timerbackup 0 604800 backup }
  if (!$isdir(backup)) { mkdir backup }
  copy -o *.ini backup\*.ini
  set %backup.date $ctime
}


This is just a really simply method. If you wanted, you could also have it compress the files or add a dialog to it. But this will work. Just include more copy commands for each file/filetype you want to back up, using the same format as the *.ini one. Also, feel free to format the last backup date/time however you like.

USE:
/backup ---- Backup up one time.
/backup daily ---- Backup immediately and once every day.
/backup weekly ---- Backup up immediately and once every week.
/backup time ---- Display the date/time it was last backed up.


Invision Support
#Invision on irc.irchighway.net
#162208 15/10/06 03:13 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Building on that...
Here's how to backup files into a .rar archive with todays date in the name which you could move or create in a specified directory.
Code:
alias backup2rar {
  var %a =  [color:blue]mirc.ini addrbk.ini control.ini servers.ini[/color]
  [color:gray]; Add the files you want backed up into the var above[/color]
  var %f = $+(flist.,$ticks,.txt)
  tokenize 32 %a
  write %f $*
  run -n [color:green]winrar.exe[/color] a [color:orange]$+(Backup.,$time(yyyymmdd),.rar)[/color] $+(@,%f)
  .timer.r.flist 1 30 .remove %f
}

I'm unsure if you need the full path to winrar.exe or not (I don't, but I do add a lot of common apps to my AppPaths registry key myself smile)

#162209 15/10/06 06:39 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Hmm, looking again at that code, theres a couple minor mistakes there...
Change: if ($1 == [color:red]$time) { echo -a $date(%backup.date,hh:nn:sstt - mm/dd/yyyy) | return }[/color]
To: if ($1 == [color:blue]time) { echo -a $date(%backup.date,hh:nn:sstt - mm/dd/yyyy) | return }[/color]

Change: copy -o *.ini [color:red]backup\*.ini
To: copy -o *.ini [color:blue]backup\

#162210 15/10/06 08:19 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Heh... typo on time as I am used to doing $time. As for the copy command, I generally do it the way I displayed while in DOS. I'm not sure if it fails in mIRC that way. I know it's not necessary, but I do it that way to prevent any possible errors (such as forgetting the \ and having it copy everything into a file called backup). wink


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard