B4J Question Backup to USB stick

strupp01

Active Member
Licensed User
Longtime User
I have the following problem:
In my program, a data backup of the database is to be done on a USB stick. For this I can select the backup path in a memo and save it in the database. At the program end, the memory path is read from the DB and the DB is saved to the USB memory stick.
This works good first.
If, however, another external USB device with a smaller drive letter is removed from the PC, the drive letter of the USB flash drives changes and the backup does not work because the old drive letter is still stored in the backup path in the DB.
What are the possibilities for solving this problem?
 

eps

Expert
Licensed User
Longtime User
What OS are we talking about? This doesn't sound like Windows or MacOS behaviour...

I would try and grab an ID or something similar of the device as well - it must have a constant 'something' to identify itself to the OS
 
Upvote 0

strupp01

Active Member
Licensed User
Longtime User
We're talking about Windows 7. a built-in hard drive with 2 partitions drive C: and D: and additionally a burner as E:
If I have 2 USB sticks additionally connected, so are the drives F: and G:
On drive G: is to be saved. The backup path is also G: and is stored in the DB.
If I now remove the USB stick F: from the PC, the other USB stick from drive G: to drive F:
My backup path is no longer correct.
This is the problem because I can not back up any more programmatically.
 
Upvote 0

AHilton

Active Member
Licensed User
Longtime User
- In your database, store the path of your backup without the drive letter ("/backups/" for example)
- Put a file on the USB drive you want to use for backups. Call it "iamthe.backup" or whatever you want.
- Each time that you want to do a backup, run through all available drive letters. See if "iamthe.backup" file is there.
- If not, go to the next available drive and test for "iamthe.backup".
- If it is found, you've found your USB drive.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
I think, there is something wrong in your description: i have very often two usb sticks in use, and i have never seen the effect you descripe. The only effect i know is this: you can have two sticks in use, each set to letter f:; if you use them together, the second one no has to change to the next letter g:, but i have never seen the reverse effect (since 1999, when the usb was working the first time)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
you can force your stick to drive letter x: for example. or use the subst command to map drive letter x: to f: or g:
 
Upvote 0
Top