This page has been archived and some links may not work correctly anymore. No updates of this page will be done anymore.
Contents of this page:
- Introduction
- Setup
- Restoring a backup
- Use manual backup to clone a RAM drive
- A much more improved technique using PIM/PE for logging and reporting and optimized for large (upgraded) RAM drives
Introduction:
I have been asked in several personal emails to explain my backup mechanism in detail. I´ll do it here now:
In general, my setup does the following every night:
Checks if everything is ready to make a backup:
- checks the data bases on C:\_dat\*.?db (appointment book, phone book, notes)
- checks the main battery voltage
If everything is okay, it makes a backup of drive C:\, creates a zip file in A:\BACKUP_C which contains the whole C: drive.
The backup is discarded if the target disk is full during the process.
Notifies me using an entry in the appointment book every morning if the backup succeeded or not, and if not, why not. It can be unsuccessful due to one of the following reasons:
- insufficient battery power
- insufficient disk space on the A: drive
- a currupt database (appointments, contacts, notes)
I do a rotational backup with 2 backups existing at one time, every second day every backup is overwritten by its new version. I call these backups "a.zip" and "b.zip". So, if no error occurs, I should have two backups everytime. One which is not older than 24h and one which is not older than 48h.
The mechanism can easily be extended to make more than two rotational backups. If you have plenty of room on A: for several backups, I recommend to make more backups.
In addition I strongly recommend to backup the A: drive (probably a flash or compact flash card) to another target, such as a desktop computer, and burn it on CD-RW from time to time.
In order to make this backup procedure work reliably, I recommend that you take care to save all your work every evening, and it is good to close system manager applications (MEMO, notes, phone book, appointment book etc). A system macro will do that automatically for you if you don´t do it, but you could have forgot to save something important, and this could cause problems.
Setup:
Now in detail:
Needed programs:
- pkzip
- voltchck (checks battery voltage, by J. Korthof)
- dbcheck (checks data bases, by Curtis Cameron)
- and, if you like to see the daily greeting of the appointment book, you need greet.zip by Andreas Garzotto
All these utilities should be installed somewhere your path variable points to.
1. Create the file backup.bat somewhere where it can be found by the "path". It is assumed that you want to backup the whole C: to A:\BACKUP_C\
See my backup.bat below. If source and/or target differ, modify all relevant path information in the backup.bat and in the system macro F9 described below.
And create the directory a:\backup_c on your flash card.
2. Create two system macros (and save them! Otherwise you will lose them if you lose all you other data and have to restore the backup ;-)). I call these macros F10 and F9 (as they are called on my palmtop). You may call them whatever you like.
- F10: Closes all system manager applications and goes back to the System Manager Topcard (and makes sure a MEMO document is saved if MEMO asks if it should save)
{Filer}{Filer}{More}{Menu}{Enter}l{Enter}{More}{Menu}{Enter}l
On my German palmtop, the macro is
{Datei-Manager}{Datei-Manager}{Mehr}{Menü}{Enter}a{Enter}J{Mehr}{Menü}{Enter}a - F9: Manages the notification: Opens MEMO, loads a:\backup_c\report.txt (adjust path if necessary!), marks the reporting line (shift-cursor-down), copies to clipboard, exits MEMO, launches appointment book, makes sure the appointments window is open (F9), jumps to today (F5, F4), creates a new appointment (F2), pastes the clipboard as title, sets the start to 8am (adjust if you prefer another time), sets the stop time to 8.01am (adjust...), disables notification (take care you enter the space after the two tabs!), 5*tab to the weekly and monthly view and disable both (spaces!), save with F10 and exit appointment book:
{Memo}{F9}a:\backup_c\report.txt{Enter}{Shift+Down}{Copy}
{Menu}q{Appt}{F9}{F5}{F4}{F2}{Paste}{Tab}8{Tab}8.01
{Tab}{Tab} {Tab}{Tab}{Tab}{Tab}{Tab} {Tab} {F10}{Menu}q
The German version is:
{Memo}{F9}a:\backup_c\report.txt{Enter}{Ums+Ab}{Kopie}
{Menü}e{KAL}{F9}{F5}{F4}{F2}{Einfg}{Tab}8{Tab}8.01
{Tab}{Tab} {Tab}{Tab}{Tab}{Tab}{Tab} {Tab} {F10}{Menü}e
3. Create 3 appointments in the appointment book early in the morning when you don't expect to use your palmtop, for example at around 2am. Preserve the time differences I used. Increase the time difference between the second and the third appointment, if your backup takes longer than about 10 minutes for a backup (e.g. if you have a huge C: drive to back up or a single speed palmtop. Maybe consider increasing the battery voltage limit in backup.bat!).
- 2:00am:||10
(calls system macro 10) - 2:01am: |c:\batch\backup.bat a |
(calls backup.bat with parameter a (so it creates a.zip) (replace path by your custom path) and reserves all available memory for that backup.bat) - 2:15am: ||9
(calls system macro 9)
Set for all these appointments:
Stop time: 1 minute after start time,
Location: Q
Notification: activated, 0 minutes,
no weekly and monthly view.
Set for the 1st and 3rd one: Repetition: daily until 1.1.2020
Set for the second: Repetition: every second day (daily, cycle=2 days) until 1.1.2020
Here you can see how it looks in my appointment book. You can even see a notification that the backup was successful at 8am.
4. Copy the second appointment (2:01) and paste it into the day after the one you created the other appointments in, and change its title to |c:\batch\backup.bat b | (apply the change to all occurrencies of this appointment, when you are asked).
Take care all other settings match the settings of the original appointment. Go a few days ahead and see if the repititions are set correctly. You should now have three appointments every day, and the one which calls backup.bat should have a and b as parameters, alternating.
Here you can change the behaviour of the rotational backup. You can create as much different "backup.bat" calling appointments as you like, giving parameters with different names. So you can set 5 different appointments with "backup.bat a", "backup.bat b", "backup.bat c" and so on. Or 10 or 20. Just be sure you have one of them each day and you have enough disk space available on the target drive.
Of course you can also create the appointments weekly instead of daily, this may be better if you don´t use your palmtop very often.
BTW: You can also call backup.bat from the command line, if you want to make a manual backup e.g. when you plan to take apart the palmtop or install some new dangerous software ;-). Just call "backup m" and you will do a manual backup, called m.zip. You will see the report, which you usually see in the appointment book at 8am, at the end of the manual backup.
5. Either disable the daily greeting of the appointment book (menu "options") or modify the time it is shown each day with Andreas Garzotto's greetime.com from the greet.zip package mentioned above. The greeting has to be shown AFTER the notify macro is executed, e.g. I could call greetime 0500 in order to let appointment book show my daily greeting not before 5am, so it doesn´t interfere with the backup routine and even shows its report when popping up.
Have fun and take care of your data!
@echo off REM backup.bat by Daniel Hertrich REM http://www.hermocom.com/knowledgebase/hplx/backuplx echo ERROR CREATING REPORT.TXT > a:\backup_c\report.txt a: REM Change 2.40 to 2.30 if you use Alkalines. 2.40 is good for REM Rechargeable batteries a:\bin\voltchck.exe 2.40 if errorlevel 1 goto power REM ============================================= REM You can put other nightly jobs in here, too! REM ============================================= dbcheck c:\_dat\*.?db > a:\dbcheck.log if errorlevel 2 goto dberror REM now create today's backup, first with a temporary name a:\bin\pkzip -rp -es -whs -Jhrs a:\backup_c\%1_temp.zip c:\*.* if errorlevel 14 goto space REM delete old version of backup del a:\backup_c\%1.zip > nul a: cd \backup_c REM rename today's backup to %1.zip ren %1_temp.zip %1.zip echo Backup %1 was successful > a:\backup_c\report.txt goto end :dberror echo Backup %1 FAILED (see a:\dbcheck.log) > a:\backup_c\report.txt goto end :power echo Backup %1 FAILED (battery) > a:\backup_c\report.txt goto end :space echo Backup %1 FAILED (disk space) > a:\backup_c\report.txt goto end :end REM print report to screen type a:\backup_c\report.txt
And here you can see the contents of my C: drive (about 4MB currently) on the left side zipped to the a.zip and b.zip in a:\backup_c on the right side, the file report.txt is also shown
If you ever get in trouble with your C: drive you now have a fairly up-to-date backup on your flash card. But what to do to get it back onto C:?
Here is a suggestion how to handle fast data recovery:
Everytime I boot my palmtop with the flash card inserted (and that is usually the case) it looks on the flash card for a config.sys and if it exists, it takes this one instead of the d:\config.sys or the c:\config.sys. And if it takes a:\config.sys, it also takes a:\autoexec.bat if it exists.
Now I have a line in my a:\autoexec.bat which verifies if the C: drive is intact by looking for a specific file which is always there if the drive is intact:
if not exist c:\bin\spd31.exe goto c_deleted
label c_deleted leads to my "catastrophe handling routine", which is very simple:
:c_deleted echo c:\bin\spd31.exe is missing. The RAM drive seems to be deleted. echo In order to restore the latest backup, please enter on C:\> echo unzip -d -o a:\backup\[lastbackup].zip path a:\bin c: cd\ dir a:\backup_c goto end
So this simply tells me what to do in such a case and sets the path to a:\bin, where unzip.exe is located and it shows the contents of a:\backup_c, so I can see what the name of the latest backup is. For example, if the following is shown:
Volume in drive A is 96M-CARD Directory of A:\BACKUP_C . (DIR) 07-19-01 10:13a .. (DIR) 07-19-01 10:13a A ZIP 2035650 09-03-01 2:06a B ZIP 2051668 09-04-01 2:06a REPORT TXT 26 09-04-01 2:06a 5 file(s) 4087344 bytes 7411712 bytes free
I know that b.zip is the latest backup, so I have to use
C:\> unzip -d -o a:\backup_c\b.zip
to restore my C: drive.
Please make sure unzip.exe (or pkunzip.exe) is available on your flash card, otherwise you would have a big problem. pkunzip uses the same switches as unzip, so the command line would be
C:\> pkunzip -d -o a:\backup_c\[lastbackup].zip
The switch "-d" creates all needed directories, "-o" overwrites without prompting. Sometimes I have to set the settings in the config utility of system manager anew after a backup restore (time, date, owner, time / date format...). And appointment book (and alarm clock, if you have and use it) has to be started once in order to make the next alarms work.
Use manual backup to clone a RAM drive:
By the way: This technique is ideal for cloning RAM drives of palmtops:
If you wish to copy a RAM drive 1:1 from one palmtop to another, simply put the flash card into the original one, type
C:\> backup z
Put the flash card into the one which shall get the RAM drive contents of the first palmtop, initialize its RAM drive if necessary, reboot the palmtop with this flash card and type
C:\> unzip -d -o a:\backup_c\z.zip
This works of course only if the second palmtop has enough space available on its RAM drive.
A much more improved technique using PIM/PE for logging and reporting and optimized for large (upgraded) RAM drives:
I have recently upgraded my internal RAM drive to 32 MB and I switched entirely from the built-in appointment book to PIM/PE (by Andreas Garzotto). Hence my need to modify and improve the nightly backup technique.
See below my new "nightly.bat" which is still invoked by the built-in appointment book, but now without any parameter, everything regarding rotational backup is done entirely from within the batch file ("if exist ....zip move ....zip ....zip").
Download links to all needed utilities are directly in the batch file below.
@echo off REM %1: nobackup OR onlybackup OR everything REM nobackup: Only runs "other nightly jobs" REM onlybackup: overrides "other nightly jobs" REM everything: executes "other nightly jobs" AND backups. REM %2: all (only if %1 given!) - overrides AC and battery voltage REM detections and backups everything, regardless of the voltage. REM Needs: REM setit, echot, timestmp, voltchck, pkzip, dbcheck if not "%1" == "everything" goto normal if not "%2" == "all" goto normal setit lf echo ATTENTION: Light Sleep Mode deactivated during nightly runs! :normal set f=n if not "%f%"=="n" goto NOENV timestmp >> c:\_dat\pim\data\backup.pim echot "Starting nightly.bat" >> c:\_dat\pim\data\backup.pim if "%1"=="nobackup" goto OTHER if "%2"=="all" goto pow1ok voltchck 4.00 if errorlevel 1 goto noAC :pow1ok if "%1"=="onlybackup" goto NOOTHER echot "AC connected. Doing everything." >> c:\_dat\pim\data\backup.pim :OTHER REM ============= OTHER NIGHTLY JOBS: ============== echot "Start pdb2x.bat" >> c:\_dat\pim\data\backup.pim call c:\batch\pdb2x.bat nightly REM (called with %1 = nightly, so pdb2x knows that it has been invoked automatically!) echot "Done pdb2x.bat" >> c:\_dat\pim\data\backup.pim echot "Start find -r" >> c:\_dat\pim\data\backup.pim find -r echot "Done find -r" >> c:\_dat\pim\data\backup.pim REM =========== END OTHER NIGHTLY JOBS ============= if "%1"=="nobackup" goto nobackup :NOOTHER REM FROM HERE EVERYTHING IS BACKUP-RELATED! :BACK1 :zip1 echot "Zipping C:\\PROGRAMS" >> c:\_dat\pim\data\backup.pim if exist a:\backup_c\c_progr.zip del a:\backup_c\c_progr.zip pkzip -rp -ex -whs -Jhrs a:\backup_c\c_progr.zip c:\programs\*.* if errorlevel 14 goto NOSPC1 REM SHIFTING!! if exist a:\backup_c\2_c_pr.zip del a:\backup_c\2_c_pr.zip if exist a:\backup_c\1_c_pr.zip move a:\backup_c\1_c_pr.zip a:\backup_c\2_c_pr.zip if exist a:\backup_c\0_c_pr.zip move a:\backup_c\0_c_pr.zip a:\backup_c\1_c_pr.zip move a:\backup_c\c_progr.zip a:\backup_c\0_c_pr.zip goto BACK2 :NOSPC1 echot "NO SPACE (1) on A for c:\\programs backup!" >> c:\_dat\pim\data\backup.pim set f=y :noAC :BACK2 if "%2"=="all" goto pow2ok voltchck 2.40 if errorlevel 1 goto nopow2 goto pow2ok :nopow2 echot "POWER TEST (2) UNSUCCESSFUL. No Backup of c:\\*.* and f:\\*.*." >> c:\_dat\pim\data\backup.pim set f=y goto FINISH :pow2ok echot "Batteries sufficient for C: backup w/o programs." >> c:\_dat\pim\data\backup.pim echot "Checking DBs in C:\\_dat\\*.?db" >> c:\_dat\pim\data\backup.pim dbcheck c:\_dat\*.?db > a:\backup_c\dbcheck.log echot "Done. Result See a:\\backup_c\\dbcheck.log" >> c:\_dat\pim\data\backup.pim if errorlevel 2 goto dberr2 echot "Databases okay." >> c:\_dat\pim\data\backup.pim goto zip2 :dberr2 echot "DB(s) (2) FAULTY. See A:\\dbcheck.LOG ! No backup of C:\\*.* this time!" >> c:\_dat\pim\data\backup.pim set f=y goto BACK3 :zip2 echot "Zipping C:\\*.*" >> c:\_dat\pim\data\backup.pim if exist a:\backup_c\c.zip del a:\backup_c\c.zip pkzip -rp -ex -whs -Jhrs -x@a:\backup_c\omit2.pkz a:\backup_c\c.zip c:\*.* if errorlevel 14 goto nospc2 REM SHIFTING! if exist a:\backup_c\2_c.zip del a:\backup_c\2_c.zip if exist a:\backup_c\1_c.zip move a:\backup_c\1_c.zip a:\backup_c\2_c.zip if exist a:\backup_c\0_c.zip move a:\backup_c\0_c.zip a:\backup_c\1_c.zip move a:\backup_c\c.zip a:\backup_c\0_c.zip goto BACK3 :nospc2 echot "NO SPACE (2) on A for c:\\*.* backup!" >> c:\_dat\pim\data\backup.pim set f=y :BACK3 if "%2"=="all" goto pow3ok voltchck 2.40 if errorlevel 1 goto nopow3 :pow3ok echot "Batteries still good. Doing F:\\*.* Backup." >> c:\_dat\pim\data\backup.pim :zip3 echot "Zipping F:\\*.*" >> c:\_dat\pim\data\backup.pim if exist a:\backup_c\f.zip del a:\backup_c\f.zip pkzip -rp -ex -whs -Jhrs a:\backup_c\f.zip f:\*.* if errorlevel 14 goto nospc3 REM SHIFTING!! if exist a:\backup_c\2_f.zip del a:\backup_c\2_f.zip if exist a:\backup_c\1_f.zip move a:\backup_c\1_f.zip a:\backup_c\2_f.zip if exist a:\backup_c\0_f.zip move a:\backup_c\0_f.zip a:\backup_c\1_f.zip move a:\backup_c\f.zip a:\backup_c\0_f.zip goto FINISH :nospc3 echot "NO SPACE (3) on A for f:\\*.* backup! >> c:\_dat\pim\data\backup.pim set f=y goto FINISH :nopow3 echot "POWER TEST (3) unsuccessful. No F:\\*.* backup." >> c:\_dat\pim\data\backup.pim set f=y goto FINISH :nobackup echo Nobackup. No backup created (noly manually), END. goto FINISH :FINISH timestmp >> c:\_dat\pim\data\cur.pim if "%f%"=="n" echot "Backup successful!" >> c:\_dat\pim\data\cur.pim if "%f%"=="y" echot "BACKUP FAILURE! See backup.pim" >> c:\_dat\pim\data\cur.pim echo. >> c:\_dat\pim\data\cur.pim goto end :NOENV echo NO ENVIRONMENT SPACE AVAILABLE! echot "NO ENVIRONMENT SPACE AVAILABLE!" >> c:\_dat\pim\data\backup.pim echot "BACKUP FAILED! NO ENVIRONMENT SPACE AVAILABLE!" >> c:\_dat\pim\data\cur.pim :end setit lo
How it works (in words):
Usually I plug in the AC adapter before I go to sleep. Sometimes not.
I want to let nightly.bat do all its jobs if AC is plugged in (they take about half an hour), if AC is not plugged in, I want nightly.bat to leave alone backing up c:\programs entirely (since there are programs only, which don´t change too often anyway.
And if AC is not plugged in, I want nightly.bat to do the most important thing first, then all the others, and before every new action it checks the battery voltage. If the battery voltage has droppen below 2.40 volts, I want nightly.bat to finish its job instantly.
Also I want to be able to give parameters to nightly.bat in case I call it manually to control its behaviour (bypass voltage checks for example).
And the report is now created very detailled with time stamps (using my self-made utility "echot") and written into "backup.pim" for PIM/PE instead of a single line written into the appointment book.
Here is the "English translation" of nightly.bat:
IF %1 is not "everything" goto "NORMAL" IF %2 is not "all" goto "NORMAL" Deactivate light sleep mode (using setit) :NORMAL set environment variable "f" to "n" (is later used to indicate bakup failures) check if "f" is really "n", otherwise goto NOENV Create a time stamp in backup.pim and write "starting nightly.bat" to backup.pim IF %1 is "nobackup" goto OTHER (no backup, only "other nightly jobs") IF %2 is "all" goto POW1OK (bypass first power check) Volt check for 4.00 volts (only "true" if AC is plugged in, see voltchck documentation) If not true goto NOAC (no adapter plugged in) :POW1OK IF %1 is "onlybackup" goto NOOTHER (i.e. override "other nightly jobs") write "AC connected. Doing everything" to backup.pim :OTHER ... here are all the other things which I want to be done nightly, i.e. pdb2x, reindexing FIND/LX etc. IF %1 is "nobackup" goto NOBACKUP :NOOTHER (from here everything is backup-related) REM ================= Backup 1 ==================== :BACK1 (backup no 1) :ZIP1 PKZIP C:\PROGRAMS if PKZIP ends with errorlevel 14 (not enough space) goto SPC1 For rotational backup: Delete last one in the queue, shift existing ones one place forward and put new ZIP file at the end. goto BACK2 :SPC1 set variable "f" to "y" (to indicate a failure) and write failure to backup.pim REM ================= Backup 2 ==================== :NOAC :BACK2 (backup no 2) IF %2 is "all" goto POW2OK (bypass 2nd power check) Volt check for 2.40 volts IF power OK goto POW2OK, ELSE goto NOPOW2 :NOPOW2 write failure to backup.pim set environment variale "f" to "y" to indicate failure goto FINISH :POW2OK write to backup.pim that power is OK in 2nd test checking data bases (using dbcheck) IF a data base is not OK, goto DBERR2 ELSE write "databases Okay" to backup.pim goto ZIP2 :DBERR2 write "database faulty" to backup.pim set "f" to "n" to indicate failure goto BACK3 :ZIP2 Doing 2nd backup: PKZIP C:\*.* (without C:\PROGRAMS) if PKZIP ends with errorlevel 14 (not enough space) goto NOSPC2 For rotational backup: Delete last one in the queue, shift existing ones one place forward and put new ZIP file at the end. goto BACK3 :NOSPC2 write "no space" to backup.pim set "f" to "y" to indicate failure REM ================= Backup 3 ==================== :BACK3 IF %1 is "all" goto POW3OK (bypass 3rd power check) Volt check for 2.4 volts IF power OK goto POW3OK, ELSE goto NOPOW3 :POW3OK write to backup.pim that power is OK in 3rd test :ZIP3 PKZIP F:\*.* (the small RAM drive, which contains drivers, but doesn´t change often) if PKZIP ends with errorlevel 14 (not enough space) goto NOSPC3 For rotational backup: Delete last one in the queue, shift existing ones one place forward and put new ZIP file at the end. goto FINISH :NOSPC3 write "no space" to backup.pim set "f" to "y" to indicate failure goto FINISH :NOPOW3 write "no power" to backup.pim set "f" to "y" to indicate failure goto FINISH :NOBACKUP ECHO "doing no backup (only manually). END! goto FINISH write timestamp to cur.pim if "f" is "n" write "backup successful" to cur.pim if "f" is "y" write "backup FAIULURE, see backup.pim" to cur.pim goto END :NOENV ECHO "NO ENVIRONMENT SPACE AVAILABLE" write "backup failed, no environment space available" to backup.pim and cur.pim :END enable lightsleep mode (with setit)
Special thanks to Konstantin v. Witzleben for testing the whole setup, Tony Hutchins for translating the Macros from German to English and Avi Meshar for the basic idea for the way of creating the notification in the appointment book!