2011/01/19

How to backup SQL Server 2008 Express

I’m facing a lot of situations where customers prefer to use a bunch of free SQL Server 2008 Express or SQL Server 2005 Express Editions - mostly installed by every Client-Server-App they use - instead of using a paid but more powerful SQL Server.  The last time I had to use an Express Edition and implemented the backup for the databases I took the time to review my SQL backup script.
 
How to backup SQL Server 2008 (Express Edition) using the command line - the whole script is downloadable below:
  • Adjust the parameters within the sql file:
    • @BACKUP_PATH = <Backup target path> - the path where the sql server creates the media set for the backup
    • @MEDIASET_PREFIX = <Backup filename prefix> - Used to give backups meaningful names. The files get automatically a timestamp attached.
    • @RETENTION = <number of backups to keep> - Specifies the of backup sets to keep.

  • Call sqlcmd from a command line or trigger a batch job calling sqlcmd and pass through the sql script doing the backup for you:
sqlcmd -i <sqlfile> -o <logfile>

-i <sqlfile>: this sql-file to be executed
-o <logfile>: a log file for stdout redirection
Whats done within the sql script (You don't need to care about this - everything is put into the script):
  • Create a media set
EXEC sp_addumpdevice @devtype, @logicalname,@physname

@devtype: In our case set to 'disk' as we do a backup to disk not to tape.
@logicalname: the name of the mediaset created using the defined @MEDIASET_PREFIX and the current timestamp
@physname: the path and filename of the mediaset, simply the backup file
  • Iterarte through all online databases - offline databases cannot be backed up and do a backup to the created media set
DECLARE databaseNamesCursor CURSOR FOR
    SELECT 
        name
    FROM
        master.dbo.sysdatabases
    WHERE
        name != 'tempdb'
        AND DATABASEPROPERTYEX(name, 'Status') = 'ONLINE'
OPEN databaseNamesCursor;

FETCH NEXT FROM databaseNamesCursor INTO @databaseName;

WHILE @@FETCH_STATUS = 0
BEGIN
    /* create a backup of the current database*/
    BACKUP DATABASE @databaseName TO @mediaset;
    FETCH NEXT FROM databaseNamesCursor INTO @databaseName;
END

CLOSE databaseNamesCursor;
DEALLOCATE databaseNamesCursor;
  • Delete not needed backups 
sp_dropdevice @logicalname, @delfile='DELFILE'

@logicalname: the name of the mediaset to delete
@delfile: if set to 'delfile' the physical file behind the mediaset will be deleted


Download the files: 
- link broken, suggest  you send me an email if you need the scripts -

2011/01/10

The owner () of job does not have server access.

New week new troubles: SnapManager SQL created some backup jobs within the SQL Server 2005 - the job itself could not be run/executed.

The owner (...) of job <Job Name> does not have server access.

This strange behaviour i got only with SQL Server 2005. With SQL Server 2008 i could not reproduce it.  The user who created the job and was the owner of the job had SQL sysadmin role assigned. I found some hints to this behaviour: a restart of the SQL Server Agent should work. In my case i didn't work that easy. 

If i change the owner of the job to the builtin user sa the job is able to run...

It would be nice to understand the issue....

2011/01/06

Can’t create a new Receive connector after installing Update Rollup 1 for Exchange Server 2007 Service Pack 3

Recently i had to migrate Exchange Server 2007 to another host. I installed the latest release with SP3 included and ran the install of the Update Rollup 1 for Exchange Server 2007 Service Pack 3. Pretty easy straight forward until i tried to create a new Receive Connector
  

Error:
Active Directory operation failed on xxxx.local. This error is not retriable. Additional information: The parameter is incorrect.

Active directory response: 00000057: LdapErr: DSID-0C090C26, comment: Error in attribute conversion operation, data 0, v1772
The requested attribute does not exist.


I longer research took me to the hint - i didn't expect that comming with a Service Pack - that you have to extend the AD schema prior installing Exchange Server 2007 SP3[1]:

If you want to run the Setup program in upgrade mode to perform an in-place upgrade from a beta version of Exchange 2007 SP3, you must first prepare Active Directory and the domains. 


Download the Service Pack 3  again or like in my case use the install media including the SP3 and run Setup.com /PrepareSchema agains the schema master. This should fix the LDAP errors.