Welcome to MSDN Blogs Sign in | Join | Help
Backing Up and Restoring Your XP Embedded Database

How many of you have installed one of the updates to the XP Embedded Database (SP1 to SP2, or SP2 to FP2007 CTP) and encountered a message telling you that you should back up your database before proceeding?

Okay, now, how many of you are running MSDE or SQL Express and don't have any SQL administration tools installed?

Well, now there's a solution!

Windows XP Embedded Feature Pack 2007 comes with another small utility in the ValueAdd folder on the CD, called DBRestore. This little tool can back up and restore your database, provided you have any version of SQL Server (MSDE, SQL Express, SQL 2000, SQL 2005, etc) installed.

In fact, it can back up remote databases too, if you have administrator access to the machine where the database resides. To use DBRestore, open a CMD window and navigate to your FP2007 CD (or the folder where you expanded the CD image), then go to the ValueAdd folder. Now, just run DBRestore.vbs as follows (this is a direct copy of the usage text from the program):

DBRestore.vbs v1.21
Backup and Restore Utility for Windows XP Embedded Databases.

Command-Line Usage:
  DBRESTORE ComputerName BackupPath [/CB|/CREATEBACKUP]

Parameters:
----------
ComputerName (required)
  Can be "local" (no quotes) or the name of a computer (local or remote).
  The named computer must be running an XP Embedded database, retail or eval.

BackupPath (required)
  Can be a local or UNC path.  Can be a path to a folder, or to a specific
  file - if a filename is specified, it must be a .MDF file (case is not
  important).  If a folder is specified, a file must exist in the folder
  matching the existing database file (unless you are creating a backup).

/CB or /CREATEBACKUP (optional)
  Specifies that you want to create a backup of the existing database.  In
  this case, BackupPath must point to a valid location to create the backup
  file.  If you do not specify a filename (with .MDF extension), DBRestore
  will create a backup filename with the same name as the existing database
  file.  (Note: DBrestore determines the correct filename to use by querying
  the database directly.)
For example, to create a backup of your existing SP2 database:
dbrestore MyServer c:\MySP2Backup.mdf /cb
To later restore this database, you would just execute the same line without the /cb switch.

Note that this tool only backs up your database MDF file. It does not backup your repositories. However, it does manage your repositories by automatically checking to see which repository folders correspond to the repository definitions in your database.

It will remove any that don't belong after the backed-up database is restored - for example, if you restore your SP2 database after having installed FP07, the FP07-specific repositories will be removed. However, if your SP2 database includes some custom components and repositories for, say, custom drivers or applications, those will be preserved during the restore. We hope you enjoy the final release of Feature Pack 2007!

- Matt

Posted: Monday, November 06, 2006 8:00 AM by Embedded
Filed under:

Comments

Nicolas G. said:

I always have an error when trying to run dbrestore...

Same things on 2 different machine (MSDE and SQL Express 2005)

=====

Line : 72

Char : 2

Error : The handle is invalide

Code : 80070006

Source : (null)

======

dbrestore local C:\XpeDB.mdf /cb

If I run dbrestore.vbs without arguments I also have that error.

Please help !!

# November 21, 2006 3:28 PM

Embedded said:

Nicolas,

Some basic questions:

1) Are you sure the database is attached (and not been detached through some other method e.g. SQL Server Management tool) before trying to create the backup using dbrestore?

2) Is the database still in use when you are trying to run dbrestore (e.g. a configuration is still open in Target Designer or something similar)?

3) Do you have permission to write to the C:  (or the location where you are trying to save your mdf to)?

4) Does this error also occur if you specify the actual server name (as opposed to "local")?

Lynda

# November 22, 2006 7:16 PM

nicgravel said:

first computer : Xp Pro with XPe db (MSDE). FP2007 installed.

Nothing open.

PC #2 : XP Pro XPe DB (SQL Express) SP2 installed. Nothing open.

On both, same problem. with local or computername.

I try to put the file on D and have same result. I'm admin on the machine with full access to all drives.

dbrestore without any argument gave me the error too.

the error refer to that line :

Sub WLF(text)

Hope this help....

# November 23, 2006 10:14 AM

Windows XP Embedded Team said:

Well, it appears we probably could have done a better job in our uninstall process since we're seeing

# November 23, 2006 3:10 PM

MattKell_MSFT said:

Actually, this error occurs if you attempt to run the script using "WScript.exe" rather than "CScript.exe" (the difference is between the Windows GUI script-host and the Console script-host).  You can solve this problem by either running cscript explicitly:

cscript dbrestore.vbs (params)

...or setting CScript as your default script host:

cscript //H:cscript

After running the latter command, cscript will be used by default.  This will solve this particular problem.

# November 27, 2006 2:09 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker