github.com/greenplum-db/gpbackup@v0.0.0-20240517212602-89daab1885b3/ci/scripts/icw-roundtrip.bash (about)

     1  #!/bin/bash
     2  
     3  set -ex
     4  
     5  # setup cluster and install gpbackup tools using gppkg
     6  ccp_src/scripts/setup_ssh_to_cluster.sh
     7  out=$(ssh -t cdw 'source env.sh && psql postgres -c "select version();"')
     8  GPDB_VERSION=$(echo ${out} | sed -n 's/.*Greenplum Database \([0-9]\).*/\1/p')
     9  mkdir -p /tmp/untarred
    10  tar -xzf gppkgs/gpbackup-gppkgs.tar.gz -C /tmp/untarred
    11  scp /tmp/untarred/gpbackup_tools*gp${GPDB_VERSION}*${OS}*.gppkg cdw:/home/gpadmin
    12  scp ./icw_dump/dump.sql.xz cdw:/home/gpadmin
    13  
    14  pushd ./diffdb_src
    15      go build
    16      scp ./diffdb cdw:/home/gpadmin/
    17  popd
    18  
    19  if [[ -d gp-pkg ]] ; then
    20    mkdir /tmp/gppkgv2
    21    tar -xzf gp-pkg/gppkg* -C /tmp/gppkgv2
    22  
    23    # install gppkgv2 onto all segments
    24    while read -r host; do
    25      ssh -n "$host" "mkdir -p /home/gpadmin/.local/bin"
    26      scp /tmp/gppkgv2/gppkg "$host":/home/gpadmin/.local/bin
    27    done <cluster_env_files/hostfile_all
    28  fi
    29  
    30  cat <<SCRIPT > /tmp/run_tests.bash
    31  #!/bin/bash
    32  
    33  source env.sh
    34  
    35  # Double the vmem protect limit default on the master segment to
    36  # prevent query cancels on large table creations
    37  gpconfig -c gp_vmem_protect_limit -v 16384 --masteronly
    38  gpstop -air
    39  
    40  # only install if not installed already
    41  if [[ -f /home/gpadmin/.local/bin/gppkg ]] ; then
    42    # gppkg v2 is installed here
    43    source env.sh; gppkg query greenplum_backup_restore
    44    if [ \$? -ne 0 ] ; then
    45      gppkg install -a gpbackup*gp*.gppkg
    46    fi
    47  else
    48    is_installed_output=\$(source env.sh; gppkg -q gpbackup*gp*.gppkg)
    49    echo \$is_installed_output | grep 'is installed'
    50    if [ \$? -ne 0 ] ; then
    51      gppkg -i gpbackup*gp*.gppkg
    52    fi
    53  fi
    54  
    55  # run dump into database
    56  echo "## Loading dumpfile ##"
    57  unxz < /home/gpadmin/dump.sql.xz | PGOPTIONS='--client-min-messages=warning' psql -q -f - postgres
    58  
    59  
    60  # gpbackup bug. there is a ticket open to resolve
    61  psql -d regression -c "DROP TABLE IF EXISTS public.equal_operator_not_in_search_path_table CASCADE;"
    62  psql -d regression -c "DROP TABLE IF EXISTS public.equal_operator_not_in_search_path_table_multi_key CASCADE;"
    63  
    64  
    65  echo "## Performing backup of regression database ## "
    66  gpbackup --dbname regression --backup-dir /home/gpadmin/data | tee /tmp/gpbackup_test.log
    67  timestamp=\$(head -10 /tmp/gpbackup_test.log | grep "Backup Timestamp " | grep -Eo "[[:digit:]]{14}")
    68  gpbackup_manager display-report \$timestamp
    69  
    70  # restore database
    71  echo "## Performing restore of regression database ## "
    72  time gprestore --timestamp "\$timestamp" --backup-dir /home/gpadmin/data --create-db --redirect-db restoreregression
    73  
    74  ./diffdb --basedb=regression --testdb=restoreregression &> ./dbdiff.log
    75  grep "matches database" ./dbdiff.log
    76  if [ \$? -ne 0 ] ; then
    77      echo "ERROR: ICW round-trip restore did not match"
    78      cat ./dbdiff.log
    79      exit 1
    80  fi
    81  echo "ICW round-trip restore was successful"
    82  SCRIPT
    83  
    84  chmod +x /tmp/run_tests.bash
    85  scp /tmp/run_tests.bash cdw:/home/gpadmin/run_tests.bash
    86  ssh -t cdw "/home/gpadmin/run_tests.bash"