Source language: Translate to:

Backup routine to USB when Drive letter changes

General questions about NeoBook

Moderator: Neosoft Support

Backup routine to USB when Drive letter changes

Postby BRobinsonS » Mon Apr 03, 2017 12:39 pm

I created a backup routine for my projects (in each program).
It has been working fine except for one situation.

One of the options is to backup to a USB drive and the path is kept in the database.
I do have a Button to update the path.

The problem comes in when the path is saved as e:\backup but the USB drive gets changed to f:\backup.
Seems to occur when I put a USB drive in first then remove it and put in the 'backup' USB drive.

What is would like to happen is an error message of my own suggests that the path doesn't exist because drive letter is not correct.
I looked at variable [LastError] with example but not sure when it occurs to stop the message 'Database backed up and/or Program backed up'.

Example Code to backup MDB file and Optional backup of EXE currently is:

Code: Select all
If "[RadioGroup1]" "=" "Other"

  FolderExists "[MembersGone.Settings.BackupPath]" "[BackupOtherExists]"
  If "[BackupOtherExists]" "=" "False"
    CreateFolder "[MembersGone.Settings.BackupPath]"
  Else
    AlertBox "Folder Exists" "Folder [MembersGone.Settings.BackupPath]"
  Endif

  If "[DayNum]" "<" "10"
    SetVar "[AddZeroDay]" "0"
  Else
    SetVar "[AddZeroDay]" ""
  EndIf
 
  FileCopy "[PubDir]RCLDeceased.mdb" "[MembersGone.Settings.BackupPath]\RCLDeceased-[Year][Month][AddZeroDay][DayNum] T[Hour][Minute].mdb"

  MessageBox "Program Backup" "Database is backed up. |Do you want to back up MembersGone program too?" "No|Yes" "[BackupPrg]"
  If "[BackupPrg]" "=" "1"
    AlertBox "Back Up" "Backup of Database Completed !"
  Else
    FileCopy "[PubDir]MembersGone.exe" "[MembersGone.Settings.BackupPath]\MembersGone-[Year][Month][AddZeroDay][DayNum] T[Hour][Minute].exe"
    AlertBox "Back Up" "Backup of Database AND Program Completed !"
  EndIf

EndIf
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: Backup routine to USB when Drive letter changes

Postby Gaev » Mon Apr 03, 2017 5:14 pm

Brian:

I tried this code ...
Code: Select all
FolderExists "c:\" "[Result1]"
FolderExists "d:\" "[Result2]"
FolderExists "e:\" "[Result3]"
AlertBox "Exists ?" "[Result1] ... [Result2] ... [Result3]"

... and I got True ... True ... False ... because my laptop has a C Drive and a D Drive ... but no E Drive.

So, a quick and dirty method would be to check for specific root folders ... if the root folder does not exist, then the Drive doesn't either.

Or better still, if you can have a permanent dummy folder on your USB Drive (e.g. \MyArchives) ... then check for this specific folder.

If this works, just store the backup folder name (without the drive letter) in your database ... then pre-pend the Drive letter at run time.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Backup routine to USB when Drive letter changes

Postby mishem » Tue Apr 04, 2017 1:50 am

You can look further in this direction

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Portable Devices\Devices
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Backup routine to USB when Drive letter changes

Postby BRobinsonS » Wed Apr 05, 2017 2:05 pm

Gaev,
Thank you for the simple solution i.e. testing for Root folders.
I will try to use the idea in my backup routine.

I did notice your test for d:\ came up 'true'.
My test needed a disc in the d:\ to result in true.

I was pleased that the FolderExists function didn't cause any error messages to have to deal with.
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: Backup routine to USB when Drive letter changes

Postby Gaev » Wed Apr 05, 2017 3:57 pm

Brian:

I did notice your test for d:\ came up 'true'.
My test needed a disc in the d:\ to result in true.

That is because my current (HP) laptop (and also my previous COMPAQ desktop) came pre-installed with the hard disk partitioned into a C: and a D: drive ... the latter (called RECOVERY) is used to store a copy of the original image of Windows ... note that I was signed in as Admin User ... if I wasn't, Windows File Manager would not show it ... so, most likely NeoBook's FolderExists would return False.

And when I insert a DVD in the DVD Dive, it is assigned E:

That is why, to be reliable across different PC configurations, best to look for a "strangely named" Folder that would be "unique to your USB Drive".
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron