Azure Paketi Windows geri yükleme: Web Siteleri

 

Şunlar için geçerlidir: azure paketi Windows

Yedekleme sırasında yaptıklarıyla aynı adlara ve yönetim hesaplarına sahip sunuculara geri yüklemeniz kesinlikle önerilir. Geri yüklemenin başarılı olması için Dosya Sunucusu ve SQL Server, yedekleme sırasındaki yapılandırma, kullanıcılar ve izinlerle tamamen aynı olmalıdır. Web Siteleri hizmetinizi geri yüklerken aşağıdaki sırayı kullanın:

1. SQL Server veritabanlarını geri yükleme

2. Dosya Sunucusunu geri yükleme

3. Web Siteleri Denetleyicisini Geri Yükleme

4. Tüm Roller üzerinde onarım çalıştırma

Geri yükleme işlemlerini gerçekleştirmek için betikleri kullanabilirsiniz. Adımlar aşağıda ayrıntılı olarak açıklanmıştır.

1. SQL Server veritabanlarını geri yükleme

SQL sunucusu Barındırma, Kaynak Ölçümü ve ana veritabanlarını geri yükleyin. SQL sunucusunun yedeklendiği adla aynı ada sahip olması gerekir.

Örnek SQL Geri Yükleme betiği

Aşağıdaki örnek betik yalnızca açıklayıcı amaçlarla sağlanır ve desteklenmez. Oluşturduğunuz betik yönetim ayrıcalıklarıyla çalıştırılmalıdır.

Not

Bu betik Microsoft tarafından desteklenmiyor.

param ([string] $backupUser = "Administrator", $backupPassword, $sqlServer, $sqlUser = "sa", $sqlPassword, $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
xcopy /Y /q \\$backupMachine\c$\$backupLocation\Hosting.bak C:\HostingOfflineFeed\
xcopy /Y /q \\$backupMachine\c$\$backupLocation\ResourceMetering.bak C:\HostingOfflineFeed\
xcopy /Y /q $backupLocation\master.bak C:\HostingOfflineFeed\
net start "SQL Server (MSSQLSERVER)" /f
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [master] FROM DISK='C:\HostingOfflineFeed\master.bak' WITH REPLACE"
net stop "SQL Server (MSSQLSERVER)"
net start "SQL Server (MSSQLSERVER)"
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [Hosting] FROM DISK='C:\HostingOfflineFeed\Hosting.bak' WITH REPLACE"
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [ResourceMetering] FROM DISK='C:\HostingOfflineFeed\ResourceMetering.bak' WITH REPLACE"
del C:\HostingOfflineFeed\Hosting.bak
del C:\HostingOfflineFeed\ResourceMetering.bak
del C:\HostingOfflineFeed\master.bak

2. Dosya Sunucusunu geri yükleme

Dosya Sunucusu, yedeklendiğinde sahip olduğu adla aynı ada sahip olmalıdır. Dosya Sunucusu bileşenlerini aşağıdaki sırayla geri yüklemelisiniz:

  1. Sertifika Paylaşımını Geri Yükleme

  2. Web Siteleri Paylaşımını Geri Yükleme

  3. Gerekirse ACL'leri yeniden uygulama

  4. Web Siteleri paylaşımında FSRM kotalarını yeniden uygulama

İki örnek betik sağlanır: biri yukarıdaki a ile c arasındaki adımlar için, diğeri de Web Siteleri paylaşımındaki FSRM kotalarını yeniden uygulamak için.

Örnek Dosya Sunucusu Geri Yükleme betiği

Aşağıdaki örnek betik yukarıdaki a-c adımlarını içerir (FSRM kotalarını geri yüklemez). Betik yalnızca açıklayıcı amaçlarla sağlanır ve desteklenmez. Oluşturduğunuz betik yönetim ayrıcalıklarıyla çalıştırılmalıdır.

Not

Bu betik Microsoft tarafından desteklenmiyor.

param ([string] $backupUser = "Administrator", $backupPassword, $certificateFolder = "C:\Certificates", $websiteFolder = "C:\websites", $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
mkdir $certificateFolder
mkdir $websiteFolder
xcopy /Y /q /E $backupLocation\ $certificateFolder
xcopy /Y /q /E $backupLocation\ $websiteFolder

FSRM kotalarını geri yüklemek için örnek betik

Aşağıdaki örnek betik FSRM kotalarını geri yükler. Betik yalnızca açıklayıcı amaçlarla sağlanır ve desteklenmez. Oluşturduğunuz betik yönetim ayrıcalıklarıyla çalıştırılmalıdır.

Not

Bu betik Microsoft tarafından desteklenmiyor.

param ([string] $backupUser = "Administrator", $backupPassword, $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
xcopy /Y /q $backupLocation\templates.xml C:\templates.xml
dirquota template import /File:C:\templates.xml
net stop srmReports
net stop srmSvc
net stop quota
net stop Datascrn
robocopy $backupLocation\SRM "C:\System Volume Information\SRM" /E /ZB /R:3 /W:5
net start Datascrn
net start quota
net start srmSvc
net start srmReports

3. Web Siteleri Denetleyicisini Geri Yükleme

Web Siteleri Denetleyicisi'ni geri yüklemek için bu bölümde sunulan Restore.ps1 PowerShell betiğini kullanabilirsiniz.

Restore.ps1 betiğini Web Siteleri Denetleyicisi'ne kopyalayın ve yönetici ayrıcalıklarıyla aşağıdaki komutu çalıştırın:

net use /Y $backupLocation /user:$backupMachineAdmin $backupMachinePassword
.\Restore.ps1 $backupLocation $encryptionKey

Not

$encryptionKey bayrağı yalnızca yedekleme sırasında kullandıysanız gereklidir.

Restore.ps1 betiği aşağıdaki gibidir.

##  Re-install and restore the controller from a backup

param ($backupPath,$password)

function ShowHelp
{
    Write-Host '===================== RESTORE.PS1 HELP ====================='
    Write-Host 'This is a script that restores based on a backup from the Hosting VSS writer'
    Write-Host 'Invoke it using .\Restore.ps1'
    Write-Host 'It can also be invoked as follows:'
    Write-Host '.\Restore.ps1 <backup path (e.g. \\backupmachine\C$\backuplocation)> <password for keys file>' 
    Write-Host ("Note: before running this script you may need to run:`r`n" + ' "net use /Y <backup path> /user:<username> <password>"')
    Write-Host '============================================================'
}

function CreateFeedWebAppIfNeeded ([string] $localFeedLocation)
{
    import-module WebAdministration
    $app = Get-WebApplication -Name HostingOfflineFeed 
    if ($app -eq $null) 
    {
        New-WebApplication -Name HostingOfflineFeed -Site 'Default Web Site' -PhysicalPath $localFeedLocation -ApplicationPool DefaultAppPool -Force
    }
    # Add mime types needed for downloading .msp files for offline installations
    $msp = Get-WebConfiguration //staticContent/* | where {$_.fileExtension -eq '.msp'}
    if ($msp -eq $null) 
    {
        Add-WebConfiguration //staticContent -Value @{fileExtension=".msp";mimeType="application/octet-stream"}
    }

    # Add mime types needed for downloading .msu files for offline installations
    $msu = Get-WebConfiguration //staticContent/* | where {$_.fileExtension -eq '.msu'}
    if ($msu -eq $null) 
    {
        Add-WebConfiguration //staticContent -Value @{fileExtension=".msu";mimeType="application/octet-stream"}
    }
}

function InstallController ([string]$offlineFeedUrl, [string]$customFeed) 
{
    $WebPiCmd = ([System.Environment]::ExpandEnvironmentVariables("%ProgramW6432%\Microsoft\Web Platform Installer\WebpiCmd.exe"))    
    if (!(Test-Path $WebPiCmd))
    {
        $WebPiCmd = Join-Path -Path $localFeedLocation -ChildPath "bin\WebpiCmd.exe"
    }
    Invoke-Command -ScriptBlock { & $WebPiCmd /Install /Products:HostingController /AcceptEula /XML:$offlineFeedUrl /SuppressReboot /Log:HostingController.log }

    if ($lastexitcode -ne $null -And $lastexitcode -ne 0) 
    {
        Write-Host "ERROR: There was a problem installing using WebPI!"
        exit $lastexitcode
    }
}

function DecodeBase64($string)
{
    return [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($string))
}

function DecryptString($EncryptedFile, $Passphrase, $salt, $init) 
{ 
    $encryptedStrings = (Get-Content $EncryptedFile)
    $ret = @()
    foreach ($Encrypted in $encryptedStrings)
    {
        # If the value in the Encrypted is a string, convert it to Base64 
        if($Encrypted -is [string])
        { 
            $Encrypted = [Convert]::FromBase64String($Encrypted) 
        } 
        # Create a COM Object for RijndaelManaged Cryptography 
        $r = new-Object System.Security.Cryptography.RijndaelManaged 
        # Convert the Passphrase to UTF8 Bytes 
        $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase) 
        # Convert the Salt to UTF Bytes 
        $salt = [Text.Encoding]::UTF8.GetBytes($salt) 
        # Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits 
        $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, "SHA1", 5).GetBytes(32) #256/8 
        # Create the Intersecting Vector Cryptology Hash with the init 
        $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]
        # Create a new Decryptor 
        $d = $r.CreateDecryptor() 
        # Create a New memory stream with the encrypted value. 
        $ms = new-Object IO.MemoryStream @(,$Encrypted)
        # Read the new memory stream and read it in the cryptology stream 
        $cs = new-Object Security.Cryptography.CryptoStream $ms,$d,"Read" 
        # Read the new decrypted stream 
        $sr = new-Object IO.StreamReader $cs 
        # Return from the function the stream 
        $ret += $sr.ReadToEnd()
        # Stops the stream
        $sr.Close() 
        # Stops the crypology stream 
        $cs.Close() 
        # Stops the memory stream 
        $ms.Close() 
        # Clears the RijndaelManaged Cryptology IV and Key 
        $r.Clear() 
    }
    return $ret
}

if ($backupPath -and $backupPath.Contains('/?'))
{ 
    ShowHelp
    return
}

Write-Host 'Starting the hosting restore process. Run with /? to see help.'
Write-Host ("Note: before running this script you may need to run:`r`n" + ' "net use /Y <backupPath> /user:<username> <password>"')
# argument parsing
if (!$backupPath)
{
    $backupPath = Read-Host "Please enter the name of the backup path (e.g. \\backupmachine\C$\backuplocation)"
}
if (!$password)
{
    $password = Read-Host "Please enter the password of the keys file" -AsSecureString
    $password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
}

$systemDrive = [System.Environment]::ExpandEnvironmentVariables('%systemdrive%\')
# Fetch restore data from remote machine
$localFeedLocation = ($systemDrive +'HostingOfflineFeed\')
$c = 0
do
{ 
    $c++
    "D" | xcopy /q /Y (Join-Path -Path $backupPath -ChildPath "HostingOfflineFeed") "$localFeedLocation" /E
} while ($c -lt 10 -and !$?)
# Install the IIS cmdlets
$dismLocation = Join-Path -Path $systemDrive -ChildPath 'Windows\System32\dism.exe'
& $dismLocation /online /enable-feature /featurename:IIS-ManagementScriptingTools /all
CreateFeedWebAppIfNeeded $localFeedLocation

Stop-Service ResourceMetering -ErrorAction SilentlyContinue
# install webpi
$wpi = (dir ($systemDrive + 'hostingofflinefeed\installers\HostingWebPlatformInstaller') -r -i 'wpi.msi').DirectoryName
if ($wpi.Count -gt 1)
{
    $wpi = $wpi[0]
}
$wpi = Join-Path -Path $wpi -ChildPath "wpi.msi"
msiexec /quiet /i $wpi
$offlineFeedUrl = 'https://localhost/HostingOfflineFeed/feeds/latest/WebSites0.9.0.xml'
InstallController $offlineFeedUrl
$keys = DecryptString (Join-Path -Path $backupPath -ChildPath 'encryptedkeys.txt') $password 'salt12345' 'init12345'
Stop-Service WebFarmService -ErrorAction SilentlyContinue
Add-PSSnapIn WebHostingSnapIn
# Restore the keys
# Keys are Base64 encoded
Set-ControllerConnectionString -ConnectionString (DecodeBase64($keys[0])) 3>$null
# Set-MeteringConnectionString -MeteringConnectionString (DecodeBase64($keys[1])) -ServerName (HostName)
Set-SymmetricKey -SymmetricKeyName SystemCore -SymmetricKey (DecodeBase64($keys[1])) 3>$null
Set-SymmetricKey -SymmetricKeyName SiteRuntime -SymmetricKey (DecodeBase64($keys[2])) 3>$null
Set-MeteringConnectionString -MeteringConnectionString ([Microsoft.Web.Hosting.SiteManager]::GetMeteringConnectionString()) -ServerName (HostName) 3>$null

Start-Service WebFarmService -ErrorAction SilentlyContinue

Farklı adlara veya yönetim hesaplarına sahip dosya olmayan sunuculara geri yükleme

Bir sunucuyu (Filer Server veya SQL Server olmayan) sunucuya veya sunucu adlarına veya yönetim hesaplarına sahip ve özgün sunuculardan farklı sunuculara geri yüklemeniz gerekiyorsa:

  1. Web Siteleri modülünü içeri aktarma

  2. Kimlik bilgilerini güncelleştirin

  3. Eski sunucu adlarını grubundan kaldırma

  4. Yeni sunucuları uygun sunucu gruplarına ekleme

  1. İlk olarak, diğer komutlardan herhangi birini çalıştırmadan önce WebSites modülünü içeri aktarın:

    Import-Module WebSites
    

    Şimdi Denetleyicide 2-4 komutlarını Yönetici olarak çalıştırın.

  2. RoleType> için< kimlik bilgileri değiştiyse, değiştirilen her kimlik bilgisi için aşağıdakileri çalıştırın:

    Set-WebSitesConfig Credential -CredentialName <RoleType> Credential -UserName <RoleAdminUser> -Password <RoleAdminPassword>
    

    Not

    Set-WebSitesConfig komutundaki RoleType> için< olası değerler şunlardır: ManagementServer, FileServer, FrontEnd, Publisher ve Worker.

  3. Artık kullanılmayan EskiAdı adlı her eski sunucu için <şunu çalıştırın:>

    Remove-WebSitesServer -Name <OldName>
    
  4. RoleType'ın<>Yeni Adı> adlı her yeni sunucu için< şunu çalıştırın:

    New-WebSitesServer -Name <NewName> -ServerType <RoleType>
    

    Not

    New-WebSitesServer komutundaki RoleType> için< olası değerler şunlardır: ManagementServer, FileServer, LoadBalancer, Publisher ve WebWorker.

Örnek

"OldWorker" adlı eski bir Web Çalışanı rolünüz ve "NewWorker" adlı yeni bir Web Çalışanı rolünüz varsa ve WebWorker kimlik bilgilerini "WebWorkerAdmin" olarak güncelleştirdiyseniz şunu çalıştırabilirsiniz:

Import-Module WebSites

Set-WebSitesConfig Credential -CredentialName WorkerCredential -UserName WebWorkerAdmin -Password $WebWorkerPassword

Remove-WebSitesServer -Name OldWorker

New-WebSitesServer -Name NewWorker -ServerType WebWorker

4. Tüm Roller üzerinde onarım çalıştırma

Geri yüklemeyi tamamladıktan sonra tüm roller üzerinde bir onarım çalıştırın ve bunların iyi durumda olduğunu doğrulamak için bunları izleyin.

Ayrıca Bkz.

Azure Paketi Windows yedekleme: Web Siteleri
Azure Paketi Windows dağıtma: Web Siteleri