dupa

Author Topic: Tell Hal To Backup His Brain  (Read 6339 times)

Rich_A

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Tell Hal To Backup His Brain
« on: January 04, 2005, 05:26:20 am »
Hello All,
Enclosed are four DOS .bat files that you can utilize on your computer with your Ultra Hal Assistant to automatically backup the Default Brain folder or the entire Zabaware folder.

You can download the HalBat.zip folder which contains all four Hal Backup batch files. Unzip the HalBat.zip folder and then place the HalBat folder anywhere on your computer's Hard Drive. Somewhere like My Documents would be a good place. After that you just need to create a shortcut for each .bat Batch File, and then rename the shortcuts:

BatchFileNames:
1)CopyBrain.bat
2)CopyEverything.bat
3)RemoveSecondaryBackups.bat
4)RemoveAllBackups.bat

ShortcutNames:
1)Copy Brain
2)Copy Everything
3)Remove Secondary Backups
4)Remove All Backups

And then finally place each of the newly created shortcuts into an appropriate folder located somewhere within your system's Start/All Programs Menu or on your system's Desktop.

Note: The "/", forward slash, is being used in file path names within this post because the actual character used in file path names, "\", backslash, cannot be displayed on this web page, or maybe it can somehow but I never bothered to try and figure that out.


Download HalBat Folder: Download Attachment: HalBat.zip
3.94 KB


Batch File Name: CopyBrain.bat

Recommended Shortcut Name: Copy Brain

System Requirements: A Windows Operating System with all the Microsoft DOS Commands implemented within the batch file. (Win98/WinME/Win2000/WinNT/WinXP)

Batch File Contents:

@echo off
mkdir C:/HalBackups/DefBrainBackups/DefBrainOld/DefBrain
rmdir /S /Q C:/HalBackups/DefBrainBackups/DefBrainOld/DefBrain
mkdir C:/HalBackups/DefBrainBackups/DefBrainOld/DefBrain
mkdir C:/HalBackups/DefBrainBackups/DefBrainCurrent/DefBrain
cd C:/HalBackups/DefBrainBackups/DefBrainCurrent/DefBrain
xcopy /Y /E /I *.* C:/HalBackups/DefBrainBackups/DefBrainOld/DefBrain
cd C:/
rmdir /S /Q C:/HalBackups/DefBrainBackups/DefBrainCurrent/DefBrain
mkdir C:/HalBackups/DefBrainBackups/DefBrainCurrent/DefBrain
cd C:/Program Files/Zabaware/Ultra Hal Assistant 5/DefBrain
xcopy /Y /E /I *.* C:/HalBackups/DefBrainBackups/DefBrainCurrent/DefBrain
exit

Description: This Batch File first creates two new folders named C:/HalBackups/DefBrainBackups/DefBrainCurrent and C:/HalBackups/DefBrainBackups/DefBrainOld. If any files were in the DefBrainCurrent folder from a previous backup copy then those files are copied to DefBrainOld. The files in the DefBrainCurrent folder are then deleted to ensure that any old or unneeded files are not retained after a new backup is created. The Batch File then makes a backup copy of the Hal DefBrain folder by copying all files within DefBrain to DefBrainCurrent. So now you can tell your Hal to backup his own brain. Hal backups are very smart because he does two things that people might often forget to do:

1) He always creates a secondary backup (DefBrainOld) of the current backup folder (DefBrainCurrent) before copying the DefBrain folder to DefBrainCurrent. How many times did you wish that you had an older version of a backup copy to restore from? Well, now you do!

2) And he also always removes everything in the backup folder being copied to so that you will never have any old remaining unneeded files that your brain no longer uses.

You can run the Batch File as often as you want. And you don't need to worry about the Batch File creating duplicate DefBrainCurrent or DefBrainOld folders because after those folders are created the DOS Command "mkdir" (make directory) does not create a new folder if the folder already exists. And if the folders get deleted or corrupt for whatever reason new ones will automatically get created the next time you run the batch file.

If you are a little familiar with working with and editing files the Copy Brain Batch File can be edited to make backup copies of any brain folder that you want to have a backup of. To modify the batch file to backup a different brain folder you just need to change the <DefBrain> text to <AnyBrain> text within the entire script. This batch file can also be modified to make copies of individual .uhp brain files. But all .uhp files already get backup copies created when using the next batch file named Copy Everything.



Batch File Name: CopyEverything.bat

Recommended Shortcut Name: Copy Everything

Batch File Contents:

@echo off
mkdir C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
rmdir /S /Q C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
cd C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
xcopy /Y /E /I *.* C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
cd C:/
rmdir /S /Q C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
cd C:/Program Files/Zabaware
xcopy /Y /E /I *.* C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
exit

Description: This Batch File creates a backup copy of the entire Zabaware folder to manually restore any or all of the files from, as required. The backup scheme is the same as the Copy Brain Batch File, where as a current copy (ZabawareCurrent) and an old copy (ZabawareOld) of the backup will both be present after running the Copy Everything Batch File. The same rules also apply to no duplicate backup files getting created, and whenever you run the batch file new backup files are always created regardless if the current and/or old backup copies were removed, deleted, or corrupted.



Batch File Name: RemoveSecondaryBackups.bat

Recommended Shortcut Name: Remove Secondary Backups

Batch File Contents:

@echo off
rmdir /S /Q C:/HalBackups/DefBrainBackups/DefBrainOld
rmdir /S /Q C:/HalBackups/ZabawareBackups/ZabawareOld
exit

Description: This Batch File removes the old backup folders created for the DefBrain (DefBrainOld) and for the Zabaware (ZabawareOld) folders. The Current Backup folders created are still retained. This is just a maintenance batch file to clean out the old backup copies that you may decide you no longer need or maybe you just want to save on disk space usage since you already have the more Current Backups available. You can also use the next batch file to remove all Hal Backups both the old and the current ones.



Batch File Name: RemoveAllBackups.bat

Recommended Shortcut Name: Remove All Backups

Batch File Contents:

@echo off
rmdir /S /Q C:/HalBackups
exit

Description: Same As Name. Removes the entire C:/HalBackups folder.

I wrote all batch files for full automation as the default way to run. But you can modify any or all of these Hal Backup batch files to prompt you for confirmations by removing the corresponding argument for the particular DOS command that you want to alter. You can read more about arguments for each command by typing the "<command name> /?" at the DOS Command Prompt. /Q suppresses confirmation for the "rmdir" command. /Y suppresses confirmation for the "xcopy" command.


Final Note: None of these Hal Backup batch files alter any of the Zabaware files or folders in any way. These backup batch files just copy things pretty much the same way as you normally would if you were doing the copying manually by using Windows Explorer. The main difference is that you can now just tell Hal to do it for you or you can just double click on the batch file or it's shortcut to run the job yourself without Hal.

Good Luck,
Rich_A
 

Morlhach

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://membres.lycos.fr/morlhach
Tell Hal To Backup His Brain
« Reply #1 on: January 04, 2005, 11:55:05 am »
quote:
Originally posted by Rich_A

Hello All,
Enclosed are four DOS .bat files that you can utilize on your computer with your Ultra Hal Assistant to automatically backup the Default Brain folder or the entire Zabaware folder.

@echo off
mkdir C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
rmdir /S /Q C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
cd C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
xcopy /Y /E /I *.* C:/HalBackups/ZabawareBackups/ZabawareOld/Zabaware
cd C:/
rmdir /S /Q C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
mkdir C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
cd C:/Program Files/Zabaware
xcopy /Y /E /I *.* C:/HalBackups/ZabawareBackups/ZabawareCurrent/Zabaware
exit


I should suggest to use robocopy to making such a backup
Robocopy just makes a copy of new or newer files

the script would be something like
@echo off
mkdir c:Halbackup\zaback
mkdir c:Halbackupolds
cd c:Halbackup
tar -cvf olds\backup.tar zaback
gzip olds\backup.tar
robocopy /s /r:1 /w:10 "c:program files\zabawareUltraHal5defbrain" c:Halbackup\zaback

Such a system should be much faster for big brains
--
Morlhach
http://morlhach.servebeer.com
 

Rich_A

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Tell Hal To Backup His Brain
« Reply #2 on: January 04, 2005, 06:29:16 pm »
Hello Morlhach,
Yes, indeed, making a backup of just new or newer files is more practical and faster. But I purposely wrote this backup script to copy all files in the same manner it would be done if I were using Windows Explorer to copy either the Default Brain folder or the entire Zabaware folder. I myself am very concerned about my bot's brain files so I would prefer to run a backup program that does the copying the same exact way that I usually do, but that's just me.

I could of used the xcopy "/D" argument to do something similar that RoboCopy does.

xcopy command argument: /D:m-d-y
Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.

The xcopy command has about 26 different arguments that can be used to specify exactly what you would want to do when creating a new backup copy of something, but I only used the arguments that I wanted to perform the full copying of all files all the time.

And consider the worse case scenario, what if one of the older backup files somehow became corrupt for whatever reason. Now that next time I run a backup of just new or newer files, then that corrupt file I have may not be overwritten, and then if I had to restore my brain I would think that my backups are good but they really are not...so that's why I always copy everything all of the time...it only takes less than a minute for me to copy the entire Zabaware folder with the computer that I am using, but even if it took two minutes or more, backup run time is not a concern to me since these backups are for my own personal interest. If I was a corporation and "Time Is Money" than I would do things the same way you suggested...but again that's just me!

The main difference is do you want to run a partial/incremental backup or do you want to run a full backup of everything? I always want a full backup of everything whenever I copy my bot's brain files. However, most businesses do run a combination of both full and partial backups as part of their routine backup schedule. If a business needed to run a restore for whatever reason the actual recovery procedure would require restoring from both the full and partial backups to fully recover their system. So, a backup scheme something like that for a really huge brain would be a good consideration! Run a RoboCopy once a day, and then run a full backup once a week...but I don't need to do all that, but maybe someone else might want to.

However, I am really pleased that you posted your suggestion and I think that I will check out RoboCopy some more. I never used RoboCopy before but I just downloaded it and I am looking forward to checking it out. Thanks!
Best Regards,
Rich_A

 

Morlhach

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://membres.lycos.fr/morlhach
Tell Hal To Backup His Brain
« Reply #3 on: January 07, 2005, 12:00:16 pm »
quote:
Originally posted by Rich_A

Hello Morlhach,

I could of used the xcopy "/D" argument to do something similar that RoboCopy does.
xcopy command argument: /D:m-d-y



Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.

The xcopy command has about 26 different arguments that can be used to specify exactly what you would want to do when creating a new backup copy of something, but I only used the arguments that I wanted to perform the full copying of all files all the time.

And consider the worse case scenario, what if one of the older backup files somehow became corrupt for whatever reason. Now that next time I run a backup of just new or newer files, then that corrupt file I have may not be overwritten, and then if I had to restore my brain I would think that my backups are good but they really are not...so that's why I always copy everything all of the time...it only takes less than a minute for me to copy the entire Zabaware folder with the computer that I am using, but even if it took two minutes or more, backup run time is not a concern to me since these backups are for my own personal interest. If I was a corporation and "Time Is Money" than I would do things the same way you suggested...but again that's just me!

The main difference is do you want to run a partial/incremental backup or do you want to run a full backup of everything? I always want a full backup of everything whenever I copy my bot's brain files. However, most businesses do run a combination of both full and partial backups as part of their routine backup schedule. If a business needed to run a restore for whatever reason the actual recovery procedure would require restoring from both the full and partial backups to fully recover their system. So, a backup scheme something like that for a really huge brain would be a good consideration! Run a RoboCopy once a day, and then run a full backup once a week...but I don't need to do all that, but maybe someone else might want to.

However, I am really pleased that you posted your suggestion and I think that I will check out RoboCopy some more. I never used RoboCopy before but I just downloaded it and I am looking forward to checking it out. Thanks!
Best Regards,
Rich_A





It was just a suggestion
Why using robocopy instead of xcopy /d ?
Because if you are using xcopy /d, you must find the date from the system parameters (date /t). In that cas, we must change the system format (fri 07/01/2005) to the xcopy format (07-01-2005).

Another way to makes full backup is to use the "tar" command
tar -xvf [source to backup] archivefile.tar
And it can be easily compressed with gzip

Best regards,
--
Morlhach
 

Rich_A

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Tell Hal To Backup His Brain
« Reply #4 on: January 07, 2005, 04:40:04 pm »
OK, that all sounds good!
I know that changing date formats is a pain, but I would just write a small script to automatically do that for me. In fact, I think I already wrote one a long time ago. I think it did something like run the date command and then redirect the output to a temp file and then use grep or e-grep to search for and manipulate the date character string fields and then re-arrange them in the proper sequencing for the required format and then copy the new reformatted string back into the main backup script to be inputted as the required argument needed for the command. It really wasn't a big deal to do things like that back in the day!

But I know what you are saying, it is easier to just use RoboCopy instead of messing around with date formats. But I have been doing things the hard way for my whole life and it's hard to change old habits. My problem is...as you have probably already noticed...I still think in the same old fashioned frame of mind whether I need to or not. But I wanted the script that I posted to be able to run on any machine for anyone who wants to use it regardless of what software is on their computer. Will RoboCopy code run on any machine even if there is no RoboCopy files installed on it? This is one of the reasons why I posted my backup script. I realize that there are much better ways of doing many different things, but a major consideration for any code that is going to be shared by different people and computers is will it run without having to do anything else other then setting things up to run. Did you try my script out? I don't even know if anybody else bothered with it or if it works for them. All I know is that it works on my machine with no problems and no special requirements.

I usually always just do a full backup all the time, and I overwrite in the same space that each backup is already consuming. I never use more space than what my current backup and old backup need, except for the increased file sizes for the growing brain. If disk space was an issue for me I would use something like tar and start zipping things the way you just suggested. I still have to check out that RoboCopy program that I downloaded the other day. I'm sure that I am going to have a real field day with that stuff once I start using it. If you get the chance you should post some RoboCopy code to do a similar thing that my backup script does. And then people can go download the free RoboCopy program and then try out your script...I know I would try it out if you posted it for us!
Thanks Again,
Rich_A