zoukankan      html  css  js  c++  java
  • Azure自动化实例: 复制blog用于备份

    在Azure 自动化:使用PowerShell Credential连接到Azure, 之后, 我在项目中遇到了实现blog备份的任务, 现将其作为一个实例写下来:

    1. 首先,创建自动化帐户, 在资产中, 创建以下资产:

    • 创建PowerShell连接Credential

    变量名:PSCredential , 设置为您的自动化账户邮箱和密码。

    • 创建脚本中要使用的字符串变量:脚本中调用的变量包括:订阅名称(SubscriptionName)、存储帐户(StorageAccountName)、容器名称(ContainerName)、源blog名(BlogName)。

    2. 在Runbook中,导入自动化脚本:

    workflow CopyBlog
    {
    #sign in
    #Add-AzureAccount
    $Credential = Get-AutomationPSCredential -Name "PSCredential"
    $SubscriptionName = Get-AutomationVariable -Name "SubscriptionName"
    $storN = Get-AutomationVariable -Name "StorageAccountName"
    $containerN = Get-AutomationVariable -Name "ContainerName"
    $srcname= Get-AutomationVariable -Name "BlogName"
    #connect to Azure using PowerShell Credential
    Add-AzureAccount -Credential $Credential
    
    #Select the Azure subscription to use in this workflow
    Select-AzureSubscription -SubscriptionName $SubscriptionName
    
    Set-AzureSubscription -SubscriptionName $SubscriptionName -CurrentStorageAccountName $storN
    
    # copy from srcblog to trgblog
    
    $thedatetime=get-date -Format 'yyyyMMddhhmmss'
    $trgname="{0}.vhd" -f $thedatetime
    Write-Verbose $trgname
    Start-AzureStorageBlobCopy -SrcBlob $srcname -SrcContainer $containerN -DestContainer $containerN -DestBlob $trgname 
    }


    发布runbook并设置自动运行规则:

    每15天备份一次。

    步骤:

    1. 在选项卡中,单击Schedule
    2. 单击LINK TO A NEW SCHEDULE。
    3. 在Add Schedule,  Configure Schedule中, 选择DAILY。
    4. 在RECUR EVERY中,输入15。
    5. 单击完成
  • 相关阅读:
    【01】markdown语法
    H5系列之地理位置(必知必会)
    【07】像使用命令行一样使用 GitHub URL
    【11】把 GitHub 当 CMS 用
    【01】在 issue 中创建 list
    【06】GitHub WiKi
    【05】project board
    7.10-11 visudo、sudo
    7.7-9 chage、chpasswd、su
    7.1 useradd:创建用户
  • 原文地址:https://www.cnblogs.com/qixue/p/4500389.html
Copyright © 2011-2022 走看看