(CommandList
  children: [
    (C {(set)} {(-o)} {(errexit)})
    (C {(set)} {(-o)} {(nounset)})
    (C {(set)} {(-o)} {(pipefail)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:VERSION_FILE)
          op: Equal
          rhs: {(DQ (version.txt))}
          spids: [136]
        )
      ]
      spids: [136]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} {(-n)} 
                  {
                    (DQ 
                      (BracedVarSub
                        token: <VSub_Name VERSION_CONTENTS>
                        suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )})
                        spids: [155 158]
                      )
                    )
                  } {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (SimpleCommand
              words: [{(echo)} {(DQ (${ VSub_Name VERSION_CONTENTS))}]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: 16777215
                  arg_word: {(DQ (${ VSub_Name VERSION_FILE))}
                  spids: [175]
                )
              ]
            )
          ]
          spids: [16777215 164]
        )
      ]
      spids: [16777215 183]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} {(KW_Bang '!')} {(-f)} {(DQ (${ VSub_Name VERSION_FILE))} 
                  {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (SimpleCommand
              words: [{(echo)} {(DQ (2.2.1/etcd2))}]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: 16777215
                  arg_word: {(DQ (${ VSub_Name VERSION_FILE))}
                  spids: [211]
                )
              ]
            )
          ]
          spids: [16777215 202]
        )
      ]
      spids: [16777215 219]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:VERSION_CONTENTS)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: (CommandList children:[(C {(cat)} {(${ VSub_Name VERSION_FILE)})])
                  left_token: <Left_CommandSub '$('>
                  spids: [223 229]
                )
              )
            }
          spids: [221]
        )
      ]
      spids: [221]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:ETCD_VERSION)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: 
                    (CommandList
                      children: [
                        (Pipeline
                          children: [
                            (C {(echo)} {($ VSub_Name '$VERSION_CONTENTS')})
                            (C {(cut)} {(-d)} {(SQ </>)} {(-f)} {(1)})
                          ]
                          negated: False
                        )
                      ]
                    )
                  left_token: <Left_CommandSub '$('>
                  spids: [234 252]
                )
              )
            }
          spids: [232]
        )
      ]
      spids: [232]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:ETCD_API)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: 
                    (CommandList
                      children: [
                        (Pipeline
                          children: [
                            (C {(echo)} {($ VSub_Name '$VERSION_CONTENTS')})
                            (C {(cut)} {(-d)} {(SQ </>)} {(-f)} {(2)})
                          ]
                          negated: False
                        )
                      ]
                    )
                  left_token: <Left_CommandSub '$('>
                  spids: [257 275]
                )
              )
            }
          spids: [255]
        )
      ]
      spids: [255]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:NAME)
          op: Equal
          rhs: 
            {
              (DQ 
                (BracedVarSub
                  token: <VSub_Name NAME>
                  suffix_op: 
                    (StringUnary
                      op_id: VTest_ColonHyphen
                      arg_word: 
                        {(etcd-) 
                          (CommandSubPart
                            command_list: (CommandList children:[(C {(hostname)})])
                            left_token: <Left_CommandSub '$('>
                            spids: [294 296]
                          )
                        }
                    )
                  spids: [290 297]
                )
              )
            }
          spids: [288]
        )
      ]
      spids: [288]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:etcd_port) op:Equal rhs:{(2379)} spids:[304])]
      spids: [304]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:event_etcd_port) op:Equal rhs:{(4002)} spids:[307])]
      spids: [307]
    )
    (FuncDef
      name: wait_for_etcd_up
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:port)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [321]
                )
              ]
              spids: [321]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:health_ok)
                  op: Equal
                  rhs: 
                    {
                      (DQ ('{') (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (health) 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (': ') (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (true) 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ('}')
                      )
                    }
                  spids: [337]
                )
              ]
              spids: [337]
            )
            (ForEach
              iter_name: i
              iter_words: [
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(seq)} {(120)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [357 361]
                  )
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:health)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (C {(curl)} {(--silent)} 
                                        {(http) (Lit_Other ':') (//127.0.0.1) (Lit_Other ':') 
                                          (${ VSub_Name port) (/health)
                                        }
                                      )
                                    ]
                                  )
                                left_token: <Left_CommandSub '$('>
                                spids: [372 385]
                              )
                            }
                          spids: [371]
                        )
                      ]
                      spids: [371]
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ (${ VSub_Name health))} 
                                  {(Lit_Other '=') (Lit_Other '=')} {(DQ (${ VSub_Name health_ok))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                          spids: [16777215 410]
                        )
                      ]
                      spids: [16777215 418]
                    )
                    (C {(sleep)} {(1)})
                  ]
                  spids: [364 426]
                )
              spids: [356 362]
            )
            (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
          ]
          spids: [318]
        )
      spids: [314 317]
    )
    (FuncDef
      name: wait_for_cluster_healthy
      body: 
        (BraceGroup
          children: [
            (ForEach
              iter_name: i
              iter_words: [
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(seq)} {(120)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [452 456]
                  )
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (AndOr
                      children: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:cs_status)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (C {(kubectl)} {(get)} {(componentstatuses)} {(-o)} {(template)} 
                                            {(--template) (Lit_Other '=') 
                                              (SQ 
                                                <
'{{range .items}}{{with index .conditions 0}}{{.type}}:{{.status}}{{end}}{{"\\n"}}{{end}}'
                                                >
                                              )
                                            }
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [463 479]
                                  )
                                }
                              spids: [462]
                            )
                          ]
                          spids: [462]
                        )
                        (C {(true)})
                      ]
                      op_id: Op_DPipe
                    )
                    (AndOr
                      children: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:componentstatuses)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (Pipeline
                                            children: [
                                              (C {(echo)} {(DQ (${ VSub_Name cs_status))})
                                              (C {(grep)} {(-c)} {(SQ <'Healthy:'>)})
                                            ]
                                            negated: False
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [487 505]
                                  )
                                }
                              spids: [486]
                            )
                          ]
                          spids: [486]
                        )
                        (C {(true)})
                      ]
                      op_id: Op_DPipe
                    )
                    (AndOr
                      children: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:healthy)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (Pipeline
                                            children: [
                                              (C {(echo)} {(DQ (${ VSub_Name cs_status))})
                                              (C {(grep)} {(-c)} {(SQ <'Healthy:True'>)})
                                            ]
                                            negated: False
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [513 531]
                                  )
                                }
                              spids: [512]
                            )
                          ]
                          spids: [512]
                        )
                        (C {(true)})
                      ]
                      op_id: Op_DPipe
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ (${ VSub_Name componentstatuses))} {(-eq)} 
                                  {(DQ (${ VSub_Name healthy))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                          spids: [16777215 559]
                        )
                      ]
                      spids: [16777215 567]
                    )
                    (C {(sleep)} {(1)})
                  ]
                  spids: [459 575]
                )
              spids: [451 457]
            )
            (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
          ]
          spids: [443]
        )
      spids: [439 442]
    )
    (FuncDef
      name: wait_for_etcd_and_apiserver_down
      body: 
        (BraceGroup
          children: [
            (ForEach
              iter_name: i
              iter_words: [
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(seq)} {(120)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [601 605]
                  )
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:etcd)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (Pipeline
                                        children: [
                                          (C {(docker)} {(ps)})
                                          (C {(grep)} {(etcd)})
                                          (C {(grep)} {(-v)} {(etcd-empty-dir)})
                                          (C {(grep)} {(-v)} {(etcd-monitor)})
                                          (C {(wc)} {(-l)})
                                        ]
                                        negated: False
                                      )
                                    ]
                                  )
                                left_token: <Left_CommandSub '$('>
                                spids: [612 644]
                              )
                            }
                          spids: [611]
                        )
                      ]
                      spids: [611]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:apiserver)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (Pipeline
                                        children: [
                                          (C {(docker)} {(ps)})
                                          (C {(grep)} {(apiserver)})
                                          (C {(wc)} {(-l)})
                                        ]
                                        negated: False
                                      )
                                    ]
                                  )
                                left_token: <Left_CommandSub '$('>
                                spids: [648 664]
                              )
                            }
                          spids: [647]
                        )
                      ]
                      spids: [647]
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ (${ VSub_Name etcd))} {(-eq)} {(DQ (0))} {(-a)} 
                                  {(DQ (${ VSub_Name apiserver))} {(-eq)} {(DQ (0))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                          spids: [16777215 712]
                        )
                      ]
                      spids: [16777215 720]
                    )
                    (C {(sleep)} {(1)})
                  ]
                  spids: [608 728]
                )
              spids: [600 606]
            )
            (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
          ]
          spids: [592]
        )
      spids: [588 591]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:MANIFEST_DIR)
          op: Equal
          rhs: {(DQ (/etc/kubernetes/manifests))}
          spids: [744]
        )
      ]
      spids: [744]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:MANIFEST_BACKUP_DIR)
          op: Equal
          rhs: {(DQ (/etc/kubernetes/manifests-backups))}
          spids: [749]
        )
      ]
      spids: [749]
    )
    (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR))})
    (C {(echo)} 
      {(DQ ('Moving etcd(s) & apiserver manifest files to ') (${ VSub_Name MANIFEST_BACKUP_DIR))}
    )
    (AndOr
      children: [
        (C {(mv)} {(DQ (${ VSub_Name MANIFEST_DIR) (/kube-apiserver.manifest))} 
          {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR))}
        )
        (C {(true)})
      ]
      op_id: Op_DPipe
    )
    (AndOr
      children: [
        (C {(mv)} {(DQ (${ VSub_Name MANIFEST_DIR) (/etcd.manifest))} 
          {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR))}
        )
        (C {(true)})
      ]
      op_id: Op_DPipe
    )
    (AndOr
      children: [
        (C {(mv)} {(DQ (${ VSub_Name MANIFEST_DIR) (/etcd-events.manifest))} 
          {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR))}
        )
        (C {(true)})
      ]
      op_id: Op_DPipe
    )
    (C {(echo)} {(DQ ('Waiting for etcd and kube-apiserver to be down'))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (Pipeline children:[(C {(wait_for_etcd_and_apiserver_down)})] negated:True)
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(echo)} {(DQ ('Downing etcd and apiserver failed'))}) (C {(exit)} {(1)})]
          spids: [16777215 853]
        )
      ]
      spids: [16777215 871]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:BACKUP_DIR)
          op: Equal
          rhs: {(DQ (/var/tmp/backup))}
          spids: [880]
        )
      ]
      spids: [880]
    )
    (C {(rm)} {(-rf)} {(DQ (${ VSub_Name BACKUP_DIR))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} {(DQ (${ VSub_Name ETCD_API))} {(Lit_Other '=') (Lit_Other '=')} 
                  {(DQ (etcd2))} {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (C {(echo)} {(DQ ('Preparing etcd backup data for restore'))})
            (C {(echo)} {(DQ ('Copying data to ') (${ VSub_Name BACKUP_DIR) (' and restoring there'))})
            (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name BACKUP_DIR) (/member/snap))})
            (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name BACKUP_DIR) (/member/wal))})
            (AndOr
              children: [
                (C {(mv)} {(Lit_Other '*') (.snap)} {(DQ (${ VSub_Name BACKUP_DIR) (/member/snap/))})
                (C {(true)})
              ]
              op_id: Op_DPipe
            )
            (C {(mv)} {(Lit_Other '*') (.wal)} {(DQ (${ VSub_Name BACKUP_DIR) (/member/wal/))})
            (C {(echo)} {(DQ ('Starting etcd ') (${ VSub_Name ETCD_VERSION) (' to restore data'))})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:image)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (C {(docker)} {(run)} {(-d)} {(-v)} 
                                {(${ VSub_Name BACKUP_DIR) (Lit_Other ':') (/var/etcd/data)} {(--net) (Lit_Other '=') (host)} {(-p)} 
                                {(${ VSub_Name etcd_port) (Lit_Other ':') (${ VSub_Name etcd_port)} {(DQ ('gcr.io/google_containers/etcd:') (${ VSub_Name ETCD_VERSION))} {(/bin/sh)} {(-c)} 
                                {
                                  (DQ 
                                    (
'/usr/local/bin/etcd --data-dir /var/etcd/data --force-new-cluster'
                                    )
                                  )
                                }
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [1027 1076]
                      )
                    }
                  spids: [1026]
                )
              ]
              spids: [1026]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(DQ ($ VSub_QMark '$?'))} {(-ne)} {(DQ (0))} 
                          {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ("Docker container didn't started correctly"))})
                    (C {(exit)} {(1)})
                  ]
                  spids: [16777215 1096]
                )
              ]
              spids: [16777215 1111]
            )
            (C {(echo)} 
              {
                (DQ ('Container ') (${ VSub_Name image) 
                  (' created, waiting for etcd to report as healthy')
                )
              }
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [(C {(wait_for_etcd_up)} {(DQ (${ VSub_Name etcd_port))})]
                          negated: True
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [(C {(echo)} {(DQ ("Etcd didn't come back correctly"))}) (C {(exit)} {(1)})]
                  spids: [16777215 1139]
                )
              ]
              spids: [16777215 1154]
            )
            (C {(echo)} {(DQ ('Etcd healthy - killing ') (${ VSub_Name image) (' container'))})
            (C {(docker)} {(kill)} {(DQ (${ VSub_Name image))})
          ]
          spids: [16777215 915]
        )
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} {(DQ (${ VSub_Name ETCD_API))} {(Lit_Other '=') (Lit_Other '=')} 
                  {(DQ (etcd3))} {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (C {(echo)} {(DQ ('Preparing etcd snapshot for restore'))})
            (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name BACKUP_DIR))})
            (C {(echo)} {(DQ ('Copying data to ') (${ VSub_Name BACKUP_DIR) (' and restoring there'))})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:number_files)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (Pipeline
                                children: [
                                  (C {(find)} {(.)} {(-maxdepth)} {(1)} {(-type)} {(f)} {(-name)} 
                                    {(DQ ('*.db'))}
                                  )
                                  (C {(wc)} {(-l)})
                                ]
                                negated: False
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [1236 1260]
                      )
                    }
                  spids: [1235]
                )
              ]
              spids: [1235]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(DQ (${ VSub_Name number_files))} {(-ne)} {(DQ (1))} 
                          {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ('Incorrect number of *.db files - expected 1'))})
                    (C {(exit)} {(1)})
                  ]
                  spids: [16777215 1282]
                )
              ]
              spids: [16777215 1297]
            )
            (C {(mv)} {(Lit_Other '*') (.db)} {(DQ (${ VSub_Name BACKUP_DIR) (/))})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:snapshot)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (CommandSubPart
                          command_list: 
                            (CommandList
                              children: [(C {(ls)} {(${ VSub_Name BACKUP_DIR)})]
                            )
                          left_token: <Left_CommandSub '$('>
                          spids: [1315 1321]
                        )
                      )
                    }
                  spids: [1313]
                )
              ]
              spids: [1313]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:image)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (C {(docker)} {(run)} {(-d)} {(-v)} 
                                {(${ VSub_Name BACKUP_DIR) (Lit_Other ':') (/var/tmp/backup)} {(--env)} {(Lit_VarLike 'ETCDCTL_API=') (3)} 
                                {(DQ ('gcr.io/google_containers/etcd:') (${ VSub_Name ETCD_VERSION))} {(/bin/sh)} {(-c)} 
                                {
                                  (DQ ('/usr/local/bin/etcdctl snapshot restore ') 
                                    (${ VSub_Name BACKUP_DIR) (/) (${ VSub_Name snapshot) (' --name ') (${ VSub_Name NAME) (' --initial-cluster ') (${ VSub_Name NAME) 
                                    ('=http://localhost:2380; mv /') (${ VSub_Name NAME) ('.etcd/member /var/tmp/backup/')
                                  )
                                }
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [1339 1397]
                      )
                    }
                  spids: [1338]
                )
              ]
              spids: [1338]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(DQ ($ VSub_QMark '$?'))} {(-ne)} {(DQ (0))} 
                          {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ("Docker container didn't started correctly"))})
                    (C {(exit)} {(1)})
                  ]
                  spids: [16777215 1417]
                )
              ]
              spids: [16777215 1432]
            )
            (C {(echo)} 
              {
                (DQ ('Prepare container exit code: ') 
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [(C {(docker)} {(wait)} {(${ VSub_Name image)})]
                      )
                    left_token: <Left_CommandSub '$('>
                    spids: [1439 1447]
                  )
                )
              }
            )
            (C {(rm)} {(-f)} {(DQ (${ VSub_Name BACKUP_DIR) (/) (${ VSub_Name snapshot))})
          ]
          spids: [1183 1203]
        )
      ]
      spids: [16777215 1466]
    )
    (C {(cp)} {(DQ (${ VSub_Name VERSION_FILE))} {(DQ (${ VSub_Name BACKUP_DIR))})
    (C {(export)} 
      {(Lit_VarLike 'CVM=') 
        (CommandSubPart
          command_list: 
            (CommandList
              children: [
                (Sentence
                  child: 
                    (Pipeline
                      children: [
                        (C {(curl)} {(DQ ('http://metadata/computeMetadata/v1/instance/attributes/'))} 
                          {(-H)} {(DQ ('Metadata-Flavor: Google'))}
                        )
                        (C {(grep)} {(-q)} {(gci)})
                      ]
                      negated: False
                      stderr_indices: [0]
                    )
                  terminator: <Op_Semi ';'>
                )
                (C {(echo)} {($ VSub_QMark '$?')})
              ]
            )
          left_token: <Left_CommandSub '$('>
          spids: [1492 1517]
        )
      }
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (DBracket
                  expr: 
                    (BoolBinary
                      op_id: BoolBinary_GlobDEqual
                      left: {(DQ ($ VSub_Name '$CVM'))}
                      right: {(DQ (1))}
                    )
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(export)} {(Lit_VarLike 'MNT_DISK=') (DQ (/mnt/master-pd))})]
          spids: [16777215 1536]
        )
      ]
      else_action: [(C {(export)} {(Lit_VarLike 'MNT_DISK=') (DQ (/mnt/disks/master-pd))})]
      spids: [1546 1556]
    )
    (C {(rm)} {(-rf)} {(DQ (${ VSub_Name MNT_DISK) (/var/etcd-corrupted))})
    (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name MNT_DISK) (/var/etcd-corrupted))})
    (C {(echo)} {(DQ ('Saving corrupted data to ') (${ VSub_Name MNT_DISK) (/var/etcd-corrupted))})
    (C {(mv)} {(/var/etcd/data)} {(DQ (${ VSub_Name MNT_DISK) (/var/etcd-corrupted))})
    (C {(echo)} {(DQ ('Copying restored data to /var/etcd/data'))})
    (C {(mv)} {(DQ (${ VSub_Name BACKUP_DIR))} {(/var/etcd/data)})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} 
                  {
                    (DQ 
                      (BracedVarSub
                        token: <VSub_Name RESET_EVENT_ETCD>
                        suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )})
                        spids: [1631 1634]
                      )
                    )
                  } {(Lit_Other '=') (Lit_Other '=')} {(DQ (true))} {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (C {(echo)} {(DQ ('Removing event-etcd corrupted data'))})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:EVENTS_CORRUPTED_DIR)
                  op: Equal
                  rhs: {(DQ (${ VSub_Name MNT_DISK) (/var/etcd-events-corrupted))}
                  spids: [1657]
                )
              ]
              spids: [1657]
            )
            (C {(rm)} {(-rf)} {(DQ (${ VSub_Name EVENTS_CORRUPTED_DIR))})
            (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name EVENTS_CORRUPTED_DIR))})
            (C {(mv)} {(/var/etcd/data-events)} {(DQ (${ VSub_Name EVENTS_CORRUPTED_DIR))})
          ]
          spids: [16777215 1647]
        )
      ]
      spids: [16777215 1702]
    )
    (C {(echo)} {(DQ ('Restarting etcd and apiserver from restored snapshot'))})
    (C {(mv)} {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR)) (/) (Lit_Other '*')} 
      {(DQ (${ VSub_Name MANIFEST_DIR) (/))}
    )
    (C {(rm)} {(-rf)} {(DQ (${ VSub_Name MANIFEST_BACKUP_DIR))})
    (C {(echo)} {(DQ ('Waiting for etcd to come back'))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (Pipeline
                  children: [(C {(wait_for_etcd_up)} {(DQ (${ VSub_Name etcd_port))})]
                  negated: True
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(echo)} {(DQ ("Etcd didn't come back correctly"))}) (C {(exit)} {(1)})]
          spids: [16777215 1764]
        )
      ]
      spids: [16777215 1778]
    )
    (C {(echo)} {(DQ ('Waiting for event etcd to come back'))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (Pipeline
                  children: [(C {(wait_for_etcd_up)} {(DQ (${ VSub_Name event_etcd_port))})]
                  negated: True
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(echo)} {(DQ ("Event etcd didn't come back correctly"))}) (C {(exit)} {(1)})]
          spids: [16777215 1803]
        )
      ]
      spids: [16777215 1817]
    )
    (C {(echo)} {(DQ ('Waiting for apiserver to come back'))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (Pipeline children:[(C {(wait_for_cluster_healthy)})] negated:True)
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(echo)} {(DQ ("Apiserver didn't come back correctly"))}) (C {(exit)} {(1)})]
          spids: [16777215 1836]
        )
      ]
      spids: [16777215 1850]
    )
    (C {(echo)} {(DQ ('Cluster successfully restored!'))})
  ]
)