Zedan IT Blog
IT definitions, discussions and more
Category Archives: Microsoft Servers
Migrate windows users profiles from a workgroup to a domain
I had to create an active directory domain for a company which is already in business for years with about 200 Desktop / Laptop computers. All of them were standalone computers and even no specific workgroup. We had to implement special services which require a domain to have a repository for account and be able to manage user settings. It seemed easy at the beginning as there was no special considerations such as migrating or upgrading or moving from old domain.
A standard practice for situations like this when you need to join these computers to the new constructed domain, you will simply join the machine to the domain then you wiil need to login to the domain with the new user account to create the new profile, then you will have to manually move all files from My Documents, Desktop, Email settings, PST files , and so on. This is a very time consuming task and will make IT support staff hate the idea of having a domain, especially that they lived for years without knowing what domain is.
I had to find a solution to do that in a simple way, as I thought if the files are stored on the hard disk, and the profile specific configuration is stored in the registry, then by making a change in the registry then the mission will be acomplished.
I started to search for topics on this issue, and found a lot of discussions on the internet by several IT proffisionals facing the same issues, and explaining how to make registry change, login/logoff/login/logoff then copy move,……. It seems very difficult and risky, as we can not afford to loose (or forget to move a file) from users profiles. And if we wanted to be wise, we should do it in the classical way. Till I found a post in a forum from a user simply advice the users to use a a tool designed for that.
I decided to to give it a try, and it was amzing to see how it did it in miniutes without errors.
The tool is “User Profile Wizard – profwiz.exe” and you can download it from http://www.forensit.com and the great thing that it is FREE.
If you download its manual, you will find that it has a lot of options and a configuration that can be saved and used later and many things. And honestly if you read it and try all the feature you will waste alot of time, while it simply can do the tasks in minutes. You can simply do the following.
Copy the tool to the computer you want to join the domain, Double Click it, the window of user account infomation will ask you about the domain you want to join and the Domain User Name. For eaxmple, if the computer has local user profile “User” and the Domain name is “CompanyDomain” and the created Domain username is “DomainUser”, then you will enter “CompanyDomain” in the field “Enter the Domain”. And enter the DomainUser in the field “Enter The Account name” – Check the box of “Join Domain” to let Profile Wizard join the computer to the domain in addition of creating the new profile.
Click Next to open the “Select User Profile Window”. In this window you will choose the local user profile that you want to migrate to the domain. The window will list all local profiles, you can select only one at a time (if you have more then one profile you can run Profwiz.exe again without checking the box of join domain and select another local profile to migrate). Then Click Next.
The next window will ask you for the Domain User account, which is the account with permission to join the domain, it could be a domain administrator account or an IT user with privilge to joint the computer to the domain.
Normally the above procedure will not take more than few minutes depending on the size of the local profile files, and when finished you will need to restart the computer and then the user can login to the domain with all his old profile setting.
Simple Windows Server Backup Script – Part 3 2008 R2
In my previous post of Backing up and restoring windows 2008 , I gave some examples of using wbadmin command in backup & restore, also I gave some idea on scheduling it and keep old backups archive.
In Windows 2008 the option Include in wbadmin command allow you to restore specific files or folders from a backup archive, but it let you only specify whole volumes to backup (taking image of them). You cannot select specific files or folders to backup.
However, in windows 2008 R2 this ability is available. You can select specific files or folders when using the -include option.
Another ability in 2008 R2 backup is you can select to backup the system state as an item. It creates a backup that includes the system state in addition to any other items that you specified with the -include parameter. The system state contains boot files (Boot.ini, NDTLDR, NTDetect.com), the Windows Registry including COM settings, the SYSVOL (Group Policies and Logon Scripts), the Active Directory and NTDS.DIT on Domain Controllers and, if the certificates service is installed, the Certificate Store. If your server has the Web server role installed, the IIS Metadirectory will be included. If the server is part of a cluster, Cluster Service information will also be included.
These two options were not available in wbadmin that comes with windows 2008.
Example:
wbadmin start backup –backupTarget:d: -include:g\folder1,h:\folder2 –systemstate
The restore operation is the same as explained for windows 2008. Please review the previous Post ” Simple Windows Server Backup Script – Part 2 2008 “
Things to remember when restoring backup:
- If your backuptarget is a volume (not a shared folder), e.g. ( -backuptarget:F: ) the folder named “WindowsImageBackup” should be on the root of that volume.
- If you are restoring registry on a Domain Controller server, you must perform the restoration in the Directory Services Recovery Mode (DSRM)
I hope this will give you a quick approach to schedule windows 2008 & 2008R2 backup. Other parameters were not discussed as I have focused on the most important.
Daily backup script for MDaemon (or other servers)
Here I will present a simple backup script for MDaemon mail server on windows 2003 in a simple, fast and efficient way.
The good thing about MDaemon server that you can simple backup the configuration & mail folders and then replace it on a freshly installed server and you get the same mail server you have before, so why not making a script to back these folders automatically.
Please note that to use this script you must configure MDaemon to start as a windows service.
Below is a simple batch file containing commands to stop the MDaemon, backup files & folders then start MDaemon again. In this batch file I use the NTbackup solution, but ofcource you can replace this with a simple xcopy batch file. I always prefer NTbackup for compression and verification.
Suppose you have a disk E: that you will take backup on, the following script will create a folder for backup every day.
Create a folder in C:\ and name it C:\scripts , then Open notepad and place the following commands and save them as backup.bat
D:\MDaemon\app\MDLaunch.exe /stop
E:
cd\
md “%date%”
cd “%date%”
echo Mail Server Windows Backup Started at: %date%_%time% >>BackupLog.txt
C:\Windows\system32\NTBACKUP.EXE backup “@C:\scripts\WinBackup.bks” /n “MAILBACKUP” /d “MAILBACKUP %date% %time%” /v:yes /r:no /rs:no /hc:off /m normal /j “Mail Server Daily Backup” /l:s /f “E:\%date%\MAILBACKUP.bkf”
echo Mail server Windows Backup Completed at: %date%_%time% >>BackupLog.txt
D:\MDaemon\app\MDLaunch.exe
This will create new folder and rename it by today’s date and place the backup “MAILBACKUP.bkf” inside it. Remember to create the BKS file for the NTbackup program (e.g. winbackup.bks) in the scripts folder which will include the MDaemon folders. For more information refer to my post on windows 2003 backup.
The first command is stop the MDaemon service and the last command is to start the MDaemon service again.
I use the echo commands to create a log file of the backup.
I hope this gave you an idea on automating backup secripts, and you can use it in other servers, for example sql server by stopping the service, copy the database files then starting the sql service again.
If you like this article the please leave a comment and if you would like to share with an article or a tip please send it to ” mohamed@mzedan.com “
Simple Windows Server Backup Script – Part 2 2008
In the first part I gave you an example of automating backup on windows 2003 server using batch files and scheduled tasks. In this second part, I will give another example on automating backup using the same technique but on windows 2008.
Windows 2008 already comes with a predefined template for scheduling backup using task scheduler but using this simple method will only have the option of backing up the whole disk (taking an image of the disk), but fortunately there is an ability to select what to backup using the wbadmincommand through the command prompt.
You must run wbadminfrom an elevated command prompt. Click Start, right-click Command Prompt, and then click Run as administrator.
First we have to prepare the backup destination, in our example here it will be a shared folder, as if you will backup to another disk, wbadmin will format it to place the image. For example the share path will be \\server01\winbackup
Create a batch file “DailyBackup.bat” which will have the following commands:
set backupshare=\\server01\winbackup << This will assign the share name to the a variable to be used in backup script
Specify the volumes to be included in the backup, remember in windows 2008 you can only select the entire volume (C: D: …) but you cannot select individual files or folders. If you use 2008 R2 you can do so and I will explain it in Part 3.
set include=c:,d: <<volume names separated by comma, volume drive letters, volume mount points, or GUID-based volume names
Make sure that you have created the three empty folders inside share1 (Today, Yesterday and Old) and rotate backup among them. Please refer to part 1 to understand why I used these three folders.
del %backupshare%\old\*.* /q
rd %backupshare%\old
ren %backupshare%\yesterday old
ren %backupshare%\today yesterday
md %backupshare%\today
Executing the wbadmin command:
wbadmin start backup -backuptarget:%backupshare%\today -include:%include% -allCritical –quiet
This will execute the image backup of the selected drives. Remember as you must take backup of the entire volume and you can not select certain items, but you can restore individual files and folders or selected items. Each time you execute this batch file will delete the oldest backup and will rename today & yesterday’s back then create new backup in today’s folder.
Scheduling the Backup operation:
Open the Task Scheduler: Control Panel > Administrator tools > Task Scheduler
From the menu select Create Task.
In the General Tab give a name to the task and select Run whether the user is logged on or not
In the Triggers tab, click New, then Select the daily time to execute the task, make sure it is enabled.
On Actions tab, click new, then select the batch file you created (DailyBackup.bat)
Click OK. A new window will open to enter the username & password of the user the task will use when executed. (e.g. username member of the backup operators and permitted to access the backup share folder)
About Restoring Backup in windows 2008:
You have to restore the backup using wbadmin, below are steps to consider:
1- Get the version number of the backup you will restore from:
wbadmin get versions -backupTarget:\\server01\winbackup\today -machine:server01
The output of the command is something similar to the following:
wbadmin 1.0 – Backup command-line tool
(C) Copyright 2004 Microsoft Corp.
Backup time: 8/12/2011 3:44 PM
Backup target: Network Share labeled \\server01\winbackup\Today
Version identifier: 08/12/2011-13:44 ß this is the version number you need
Can Recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
2-Get the Items that you can restore:
wbadmin get items -version:08/12/2011-13:44 -backupTarget:\\server01\winbackup\today -machine:server01
The output of the command is something similar to the following:
wbadmin 1.0 – Backup command-line tool
(C) Copyright 2004 Microsoft Corp.
Volume Id = {f711229f-b5cb-11e0-a3f1-806e6f6e6963}
Volume ‘<Unlabeled Volume>’, mounted at C:
Application = FRS
Component = 8C0936D1-A5B0-4F05-99E7-A79FC7873694-C018CBC4-8D91-4BAD-B92A-6E91D97AA640 (SYSVOL\8C0936D1-A5B0-4F05-99E7-A79FC7873694-C018CBC4-8D91-4BAD-B92A-6E91D97AA640)
Application = AD
Component = ntds (C:_Windows_NTDS\ntds)
Application = Registry
Component = Registry (\Registry)
3- Now you can perform one of the following tasks:
Restore the entire drive:
wbadmin start recovery -version:08/12/2011-13:44 -BackupTarget:\\server01\winbackup\today -itemType:Volume -items:c: -machine:server01
Restore System Recovery (Bare Metal)
wbadmin start sysrecovery -version:08/12/2011-13:44 -BackupTarget:\\server01\winbackup\today -machine:server01
Restore System State Recovery
wbadmin start systemstaterecovery -version:08/12/2011-13:44 -BackupTarget:\\server01\winbackup\today -authsysvol -machine:server01
Restore Registry
wbadmin start recovery -version:08/12/2011-13:44 -BackupTarget:\\server01\winbackup\today -itemType:App -items:Registry -machine:server01
Restore Files or Folders (e.g. folder1)
wbadmin start recovery -version:08/12/2011-13:44 -BackupTarget:\\server01\winbackup\today -itemType:File -items:c:\folder -recursive
Remember
- In most cases you will recover the system (restore the backup) from a connected media (volume) such as a hard Disk, DVD drive, USB drive and so on… Usually when recovering a system it rearly to restore a backup from a shared foler. Accordingly, your -backuptarget option will be a volume (e.g. -backuptarget:F:). In that case the backup folder ” WindowsImageBackup ” should be on the root of that volume.
- When berforming the backup and your backuptarget is a volume, then the backup program will format that volume and if there were old backups, they will be lost. That’s why the shared folder is used for backups in windows 2008.
In the Part 3 I will explain some differences between 2008 & 2008 R2 in executing the wbadmin.
Simple Windows Server Backup Script – Part 1 2003
“Backup” is a word every system administrator feel shake in his body when
someone mention something wrong about it. Every system , should have its
backup and backup/restore procedure. I will not get more into explain what
backup is and why it is important.
I remember when working with Windows NT 4.0 about 12 years ago how it forced us
to use backup on tapes, and how we must wait till the tape end catalog, and how
it took very long time to backup or restore, unless you had the budget to buy
special backup software. Also I remember how it was great when we found that
we can take an image of the entire disk using programs like Norton Ghost.
Fortunately , things are better now, if you did not get approval for buying
expensive backup software, you still can use automatic scheduled backup wit
archiving of old backup. Here I will present two simple solutions for windows
2003 & 2008 using what we already have in the server like NTBACKUP and WBADMIN.
Here, I will present two scripts to give you an idea about using the command
line backup tools and schedule to run on daily basis and an example of
archiving:
Suppose that you have 2003 server (Server01) and you want to schedule backup for
System Drive C: , System State, and a data folder on Drive D:
1- Make a selection of what to back and save it as a selection file.
Start Windows Backup, or from the command prompt run ntbackup.exe (start
in advanced mode, not the wizard mode). Go to Backup Tab and
select Whole Drive C: and the folder in Drive D: and Do not forget to check the
System State.
2- From Job Menu, save your selection as a .bks file. E.g. D:\Scripts\Winbackup.bks
3- Suppose you will take backup every day to drive X: and you want to keep the
backups of yesterday and the day before yesterday accessible. Example, create
three folders in drive X: (Today, Yesterday, Old).
4- Create a batch file to execute ntbackup with the saved selection into Today
Folder, while keeping the backup of Yesterday and the day before:
cd old
del *.* /q
cd ..
rd old
ren Yesterday Old
ren Today Yesterday
md Today
Then add the command to execute the NTBACKUP:
C:\Windows\system32\NTBACKUP.EXEbackup “@D:\scripts\WinBackup.bks” /n “Server01” /d “Server01 %date% %time%”
/v:yes /r:no /rs:no /hc:off /m normal /j “Server01 Daily Backup” /l:s /f
“X:\Today\Server01_Win.bkf”
5- Save the batch file into your “D:\scripts” folder
as “DailyBackup.bat”.
You can test the script by double click on the .bat file in windows explorer or
by opening the command prompt ( Start > run > cmd > press Enter) then type
“d:\scripts\dailybackup.bat”
You will notice that will create the folder “Today” in
X: then will create the backup file “Server01_Win.bkf”
inside it. After the backup finish, if you execute the batch file again, the “Today” folder
will be renamed to“Yesterday” and
a new Today folder will be created.
If you execute it once more, the “Yesterday” folder
will be renamed to “Old”,
and “Today” folder
will be renamed to “Yesterday”,
and so on….
By Executing this simple script you will have a full backup for the past three
days, you can increase the number of archives as you need by changing the
script. For example by creating folders with the names of week days.
6- Now schedule the DailyBackup.bat to run on daily basis at a specific time,
Let’s say you want it to be automatically executed everyday at 3:00 AM.
In windows 2003, open the Task Scheduler: Control Panel > Add Scheduled
Task
Click Next, Then Click Browse and select the batch file you saved in step #5
Give a name to your scheduled Task, and select Perform this task Daily
Click Next to Select the Time to run the Task automatically
Click Next and Enter the Credentials of and Administrator or Backup Operator
Account, Click Next then Finish.
You can Review the Daily Backup Task report from the Log Viewer in Task
Scheduler, and The Backup Report from The report viewer in NTBACKUP.
Also, it is wise to copy the Created BKF file to an external Storage on Daily
Basis.
In Part 2, I will explain hot to create a batch file with the WBADMIN backup
tool for windows 2008.