Many of our customers (with installed version of OfficeClip Suite) were asking us how to take backup of the database and how to avoid data loss if the server died. Most of our users run OfficeClip on Sql Express database and Microsoft does not provide Log Shipping for the Sql Server Express Edition.
So we decided to write a command line interface which would manage incremental backup and restore for our customer. Anticipating that this would be a useful solution for many other sql express users, we decided to make the source available free. Here are some of the features:
-
Full backup is taken every day (regardless of how often the program is run)
- Incremental backup is taken periodically (say 10 minutes) when the program is run
- It can keep the past backup history for a certain number of days
- Log file is created in HTML format so it is easy to read
- Backup can be restored using a single command that first restores the most recent full backup and then restores all the incremental backups in the correct order
- It is possible to use the Windows Scheduler and run the program periodically and save the files to a destination machine and restore periodically thereby simulating log shipping
- It can be run from a command prompt
Notes:
- Before running this program on a database, you must change the database to “Full Recovery Mode” from the Sql Server Express Management Studio.
- For restoring the backups make sure that the sql server user name and permission should match in both database.
- The program is released under BSD License, so that you can also use it commercially without paying any royalities whatsoever.
- It is written in C# using .net framework 2.0 in visual studio 2005 but should run on any vs.net 2008 editions.
- If you are an OfficeClip customer, the same program is available in the distribution and it is called ocbackup.exe.
Download: Source Code | Executables Only
Usage:
To see all the options, run the program: OfficeClip.OpenSource.LogShipping.exe (from the LogShipping\bin\debug folder)
Examples:
The following command takes transactional backup every time it is run, takes full backup every day, keeps old backup for 7 days for the database called officeclip. The backup files are stored in the folder E:SqlBackups. It can be run every 10 minutes using the windows scheduler.
OfficeClip.OpenSource.LogShipping -bd 7 -c backup -d officeclip -f “E:\SqlBackups” -s “Server=(local);Database=Master;Trusted_Connection=True”
The following command restores the backup to the database called officeclipR. The files are read from the folder E:SqlBackups.
OfficeClip.OpenSource.LogShipping -bd 7 -c backup -d officeclipR -f “E:\SqlBackups” -s “Server=(local);Database=Master;Trusted_Connection=True”
License: BSD License
If you download and end up using this code, please leave a note. We would like to know who is using this code.
SK Dutta is a software architect and creator of OfficeClip Suite of products. He loves to design and develop software that makes people do their job better and more fun. He always explores ways to improve productivity for small businesses. He is also an avid reader in many areas, including psychology, productivity, and business.