github.com/tuhaihe/gpbackup@v1.0.3/README.md (about)

     1  # gpbackup for CloudberryDB
     2  
     3  [![Slack](https://img.shields.io/badge/Join_Slack-6a32c9)](https://communityinviter.com/apps/cloudberrydb/welcome)
     4  [![Twitter Follow](https://img.shields.io/twitter/follow/cloudberrydb)](https://twitter.com/cloudberrydb)
     5  [![Website](https://img.shields.io/badge/Visit%20Website-eebc46)](https://cloudberrydb.org)
     6  [![GitHub Discussions](https://img.shields.io/github/discussions/cloudberrydb/cloudberrydb)](https://github.com/orgs/cloudberrydb/discussions)
     7  ![GitHub License](https://img.shields.io/github/license/cloudberrydb/gpbackup)
     8  
     9  ---
    10  
    11  `gpbackup` and `gprestore` are Go utilities for performing Greenplum database
    12  backups, which are developed by Greenplum Database team. This repo is a fork
    13  of gpbackup, dedicated to support CloduberryDB 1.0+. You will feel no change
    14  using gpbackup in CloudberryDB just as well in Greenplum.
    15  
    16  ## Pre-Requisites
    17  
    18  The project requires the Go Programming language version 1.11 or higher.
    19  Follow the directions [here](https://golang.org/doc/) for installation, usage
    20  and configuration instructions.
    21  
    22  ## Downloading
    23  
    24  ```bash
    25  go get github.com/tuhaihe/gpbackup/...
    26  ```
    27  
    28  This will place the code in `$GOPATH/github.com/greenplum-db/gpbackup`.
    29  
    30  ## Building and installing binaries
    31  
    32  Make the `gpbackup` directory your current working directory and run:
    33  
    34  ```bash
    35  make depend
    36  make build
    37  ```
    38  
    39  The `build` target will put the `gpbackup` and `gprestore` binaries in `$HOME/go/bin`.
    40  
    41  This will also attempt to copy `gpbackup_helper` to the greenplum segments (retrieving hostnames from `gp_segment_configuration`). Pay attention to the output as it will indicate whether this operation was successful.
    42  
    43  `make build_linux` is for cross compiling on macOS, and the target is Linux.
    44  
    45  `make install` will scp the `gpbackup_helper` binary (used with -single-data-file flag) to all hosts
    46  
    47  ## Validation and code quality
    48  
    49  ### Test setup
    50  
    51  Required for Greenplum Database 6 or higher, several tests require the `dummy_seclabel` Greenplum contrib module. This module exists only to support regression testing of the SECURITY LABEL statement. It is not intended to be used in production. Use the following commands to install the module.
    52  
    53  ```bash
    54  pushd $(find ~/workspace/gpdb -name dummy_seclabel)
    55      make install
    56      gpconfig -c shared_preload_libraries -v dummy_seclabel
    57      gpstop -ra
    58      gpconfig -s shared_preload_libraries | grep dummy_seclabel
    59  popd
    60  
    61  ```
    62  
    63  ### Test execution
    64  
    65  **NOTE**: The integration and end_to_end tests require a running Greenplum Database instance.
    66  
    67  To run all tests except end-to-end (linters, unit, and integration), use
    68  ```bash
    69  make test
    70  ```
    71  To run only unit tests, use
    72  ```bash
    73  make unit
    74  ```
    75  To run only integration tests (requires a running GPDB instance), use
    76  
    77  ```
    78  make integration
    79  ```
    80  
    81  To run end to end tests (requires a running GPDB instance), use
    82  ```bash
    83  make end_to_end
    84  ```
    85  
    86  **We provide the following targets to help developers ensure their code fits
    87  Go standard formatting guidelines.**
    88  
    89  To run a linting tool that checks for basic coding errors, use
    90  ```bash
    91  make lint
    92  ```
    93  This target runs [gometalinter](https://github.com/alecthomas/gometalinter).
    94  
    95  Note: The lint target will fail if code is not formatted properly.
    96  
    97  
    98  To automatically format your code and add/remove imports, use
    99  ```bash
   100  make format
   101  ```
   102  
   103  This target runs
   104  [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) and
   105  [gofmt](https://golang.org/cmd/gofmt/). We will only accept code that has been
   106  formatted using this target or an equivalent `gofmt` call.
   107  
   108  ## Running the utilities
   109  
   110  The basic command for gpbackup is
   111  ```bash
   112  gpbackup --dbname <your_db_name>
   113  ```
   114  
   115  The basic command for gprestore is
   116  ```bash
   117  gprestore --timestamp <YYYYMMDDHHMMSS>
   118  ```
   119  
   120  Run `--help` with either command for a complete list of options.
   121  
   122  ## Cleaning up
   123  
   124  To remove the compiled binaries and other generated files, run
   125  ```bash
   126  make clean
   127  ```
   128  
   129  # Code Formatting
   130  
   131  We use `goimports` to format go code. See
   132  https://godoc.org/golang.org/x/tools/cmd/goimports The following command
   133  formats the gpbackup codebase excluding the vendor directory and also lists
   134  the files updated.
   135  
   136  ```bash
   137  goimports -w -l $(find . -type f -name '*.go' -not -path "./vendor/*")
   138  ```
   139  
   140  # Troubleshooting
   141  
   142  ## Dummy Security Label module is not installed or configured
   143  
   144  If you see errors in many integration tests (below), review the Validation and
   145  code quality [Test setup](#Test setup) section above:
   146  
   147  ```
   148  SECURITY LABEL FOR dummy ON TYPE public.testtype IS 'unclassified';
   149        Expected
   150            <pgx.PgError>: {
   151                Severity: "ERROR",
   152                Code: "22023",
   153                Message: "security label provider \"dummy\" is not loaded",
   154  ```
   155  
   156  ## Tablespace already exists
   157  
   158  If you see errors indicating the `test_tablespace` tablespace already exists
   159  (below), execute `psql postgres -c 'DROP TABLESPACE test_tablespace'` to
   160  cleanup the environment and rerun the tests.
   161  
   162  ```
   163      CREATE TABLESPACE test_tablespace LOCATION '/tmp/test_dir'
   164      Expected
   165          <pgx.PgError>: {
   166              Severity: "ERROR",
   167              Code: "42710",
   168              Message: "tablespace \"test_tablespace\" already exists",
   169  ```
   170  
   171  ## How to Contribute
   172  
   173  See [CONTRIBUTING.md file](./CONTRIBUTING.md).
   174  
   175  ## License
   176  
   177  Licensed under Apache License Version 2.0. For more details, please refer to
   178  the [LICENSE](./LICENSE).
   179  
   180  ## Acknowledgment
   181  
   182  Thanks to all the Greenplum Backup contributors, more details in its [GitHub
   183  page](https://github.com/greenplum-db/gpbackup).