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. 单击完成
  • 相关阅读:
    MySQL批量更新字段url链接中的域名
    巧用Win+R
    斯坦福高效睡眠法
    chkconfig: command not found
    Nginx(./configure --help)
    Ubuntu16.04配置Tomcat的80端口访问
    Binary Tree Level Order Traversal
    java——Arrays.asList()方法
    python 发送邮件
    常用邮件协议
  • 原文地址:https://www.cnblogs.com/qixue/p/4500389.html
Copyright © 2011-2022 走看看