Darren Ferguson - Weblog
Monday, October 20, 2008
A new look for my Blog
Unless you are reading this in your RSS reader you'll probably notice that my Blog had had a little bit of a clean up. I never really liked the old layout which was a default Wordpress theme but as with most personal tasks the custom design got held up while other more pressing (and financially rewarding) things got done.
I hope you like the new design, I've gone for something that is very content-centric as this site is a blog and that is where the focus should be. I've also tried to create strong visual ties to my company site so that people create a sub conscious connection. Finally I've tried to ensure that everything is easy on the eye using colours and fonts that are easy to read on screen.
My thanks and respect go to Tony at Boldfish and Oliver at Yacada for helping me to put this together. These guys are a dream when it comes to taking a site from an idea to an end product.
Credit also to Umbraco which made templating the site a couple of hours work rather than a couple of days, proof if needed that it does an exceptional job of separating content from presentation - something that every decent CMS should.
Thursday, October 09, 2008
Update on SQL server 2005 backup/restore
This post is a response to a comment on my last blog post by Wouter.
Wouter correctly pointed out that my method for backing up the database involved taking the database temporarily off-line. By using the 'backup database' command in SQL server you can backup and restore and keep the database alive. I'd previously had problems with this, but finally sat down and worked through all of these issues so I now have a solution to share.
The backup database command is simple:
backup database umbraco to disk = 'D:\umbraco.bak';
Note: I discovered that if you run this command from within management studio express it doesn't run as you, so watch out for permissions issues.
The restore command is a little more involved.
restore database umbraco from disk = 'd:\umbraco.bak'
with replace,
move 'umbraco_Data' to 'd:\sqldata\umbraco.mdf',
move 'umbraco_Log' to 'd:\sqldata\umbraco_log.ldf'
The 'with replace' part allows you to overwrite existing data files. The move statements allow you to place your data and log files in new locations if the SQL server install directory is different from the server where the backup was taken.
If you are unsure of the names of the original data files which are provided as arguments to 'move' then you can run the following SQL against you db backup.
restore filelistonly from disk = 'd:\umbraco.bak'
The value you are interested in is the Logical Name column.
I'm now at a state where this site gets daily automated backups using the method above combined with Windows scheduled tasks and SlikSVN to push my backups to a hosted SVN repository over at beanstalk.
Next up, an article on version controlling Umbraco during development!
Wednesday, October 01, 2008
Umbraco tip: Quick SQL server 2005 backup/restore
This only works if you are using a version of SQL server and have access to a command prompt on your server. I was looking for a way to source control DB backups and quickly copy my database between development, QA and production environments.
Start with the following in a file called backup.sql - obviously change the database name.
use master go sp_detach_db 'databasename' go
In the same folder create a file backup2.sql - again the database name and paths to your SQL server install are key.
use master go sp_attach_db 'databasename', 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\databasename.mdf', 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\databasename_log.ldf' go
Next create a file called backup.bat - In this file replace the target of the copy with a path of your choice. I am just copying the files to my SVN repository for a later commit.
sqlcmd -ic:backup.sql copy "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\databasename*.*" C:\repositories\df_com\trunk\db sqlcmd -ic:backup2.sql
For sqlcmd to execute, you will need to have the SQL server bin directory in your PATH. You may also want to stop IIS prior to the backup and start it again after using net stop|start w3svc.
Now you have your SQL server data file detached and copied to a new location. To restore simply create restore.bat.
sqlcmd -ic:backup.sql copy C:\repositories\df_com\trunk\db\databasename*.* "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\" sqlcmd -ic:backup2.sql
Exactly the same process but copying the data files in the opposite direction.
So why is this useful? Well, so long as your database names and SQL server paths are the same across servers you can simply copy your data files between servers and restore the database in any environment.
This all came about as part of a larger project to put umbraco under source control which I'll write a better article on at some point later on.