Compress and move existing Windows 2012 and Microsoft SQL Server 2008 Express backups

The following has been used to backup a server with Cisco Cubac on. The software runs on Windows 2012 machine and uses SQL Server 2008 Express.
As its not on a managed server I had to find a way to backup the server and the database, plus keep the backup as small as possible.
I get the Windows backup tool to backup once a day and save it to D:\WindowsImageBackup\, I then get the script below to run which then backs up SQL Server 2008 Express separately. I then get the backups compressed with 7zip and move them to a network storage device.
The destination NAS required a username and password, I had to put in a username and password (Not recommended although I believe SAMBA may not have been configured correctly).
If the server was on the same domain as the backup destination then get rid of “/user:username Password” from the net use line, normally having an account with the same username and password should work.

This batch requires RoboCopy (I believe is installed with the OS), 7Zip, a destination device and lots of disc space to fit the backups.

This has been used on a server with Windows 2012 and Microsoft SQL Server 2008 Express to backup a Cisco Cubac install.
The script will call SqlBackup.sql to tell SQL to backup the databases (As it installed with SQL Server 2008 Express).
Everything surrounded by <> needs to be changed, anything calling a directory needs to be checked.
%hostname% is not used for ServerHostName variable, its used for the SQL instance name (Which normally is the hostname).

This second file (SQL Backup File for Microsoft SQL Server 2008 Express) is called separately, above I have called it SqlBackup.sql in the folder specified in variable BackupScript.

Synctoy 2.1 setup batch script

This code was used to speed up the setup of SyncToy 2.1 (I see no reason to backup the entire user profile folder, but I hate having to setup multiple sync jobs). As Microsoft has not updated SyncToy it may not work on anything other than Windows 7.
The script expects SyncToy 2.1 is installed and that the destination is always the H drive (For whatever reason I am not using a variable for the main location, I may update this at some point as code to select another path is already in).

Simple backup and restore scripts

Back when my workplace migrated from Windows XP to Windows 7, I became lazy and automated backing up and restoring a users profiles important files in a batch script.
Here I backup to the drive H, this drive is pretty much our standard user drive. If the user does not have a H drive some pretty neat code from https://groups.google.com/forum/#!topic/alt.msdos.batch.nt/kOsN-QIOYEY displays a folder selection box (As annoyingly some users didn’t have their home drive set as H). Although I have set the filepath as LaptopBackup I have used it on Desktops as well.
The code deliberately terminates if it detects it isn’t on Windows 7, this is purely because I haven’t tested this in a network environment on other OS’s!
Known faults are pinned shortcuts in the taskbar don’t appear and printer settings don’t migrate (I never got around to correcting it).

This section of code is to backup to %backupdir%\LaptopBackup\

This section of code is to restore from %backupdir%\LaptopBackup\

Update August 2017. I have found Windows 10 Sticky Notes needs to be moved to a different location so data can be imported, the below has been added as where I work is currently planning to migrate from Windows 7 to Windows 10.
Further amendments may be needed and obviously the backup script above doesn’t account for the new data location for Sticky Notes.
Corrected restore location of restore script April 2018 (Whoops)

Old Sites

This is just a note to acknowledge that back in 2001 until 2011 I hosted a number of Gaming websites for a number of communities.  It generated a whole $100 of revenue (never near the operating costs) but had over 20 million page views and allowed me to develop skills as a system administrator on CentOS, cPanel and various scripts which were utilised.  We went from simple shared hosting to using multiple Dedicated Servers during our peak:

Special thank’s goes to:
Half Life Improvement Team (Matt, AI and many others not mentioned)
LaggedRabbit for help with Sven Co-op Central
The BP Kr3w (Luke, Simon, Rob, Ali, Hammi, Phil and many others not mentioned)
The Lanning Crews (FrictionLan, FossLan, SIRLan)
Shawson for the designing the iconic BuLLetPain website and for the awesome Shawson&Co adventures which spawned its own website.
With Friends Like These (Lurid, Wrin, Kain and many others not mentioned)
Every clan we supported
BBQWitTehBear
SirTart (For classic whitty banter)
UKDedicated, Sagonet, Layeredtech who have hosted us over the years and provided our many download mirrors for BuLLetFiles and Sven Co-op Central.
ikonboard (The first forum used by BuLLetPain) and InvisionBoard (Used during BuLLetPain’s most popular years)
e107 (Which powered Sven Co-op Central)
RWScripts (Which powered BuLLetFiles)
BuLLetPain was started in December 2001 and closed in 2006-7 but continued supporting communities into 2011 until Sven Co-op Central closed.