timescaledb-backup
timescaledb-backup copied to clipboard
"go get" only fetches the source code
It doesn't build a binary the way other "go get" projects provide it. I am not familiar with Go, so I don't know if that is on you or on go, but it makes it a bit difficult to use the tools when not using Linux.
Same issue (osx with go installed through brew), although I was able to run the command this way:
git clone https://github.com/timescale/timescaledb-backup;
cd timescaledb-backup/cmd/ts-dump/;
go run main.go
Here's a "Dockerfile" for creating a Docker container/image that has ts-dump and ts-restore installed.
Note how it runs go mod tidy and go build after downloading with go get. I'm not sure this is the best way of installing, but it works for me in Docker
ARG VERSION
# pg_dump and pg_restore come from this base image,
# based on the TimescaleDB version one wants
FROM postgres:${VERSION}-alpine
# Copy the Golang binaries from this official image,
# rather than installing manually
COPY --from=golang:rc-alpine /usr/local/go/ /usr/local/go/
# Configure Go
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH /usr/local/go/bin:$PATH
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
# Download and build the ts-dump and ts-restore Golang packages
RUN go get -u github.com/timescale/timescaledb-backup/ || true && \
# Build ts-dump first
cd /go/pkg/mod/github.com/timescale/[email protected]/cmd/ts-dump && \
go mod tidy && \
go build -o /usr/local/go/bin/ts-dump && \
# Build ts-restore second
cd ../ts-restore && \
go mod tidy && \
go build -o /usr/local/go/bin/ts-restore
FYI, I've updated my Dockerfile so that instead of trying to go get... then go build... ts-dump, I'm now downloading the Linux x86-64 binaries and renaming them, and this seems to have updated the ts-dump version (although I have no way of verifying that). I've since tried to create backups (including my TimescaleDB materialized views and continuous aggregates) three times, and it's worked all three times! So this is the installation routine I'll run now.
ARG VERSION
# pg_dump and pg_restore come from this base image,
# based on the TimescaleDB version one wants
FROM postgres:${VERSION}-alpine
# Copy the Golang binaries from this official image,
# rather than installing manually
COPY --from=golang:rc-alpine /usr/local/go/ /usr/local/go/
# Configure Go
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH /usr/local/go/bin:$PATH
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
# Download the Linux binaries manually
RUN cd /usr/local/go/bin && \
wget https://github.com/timescale/timescaledb-backup/releases/download/0.1.1/ts-dump_0.1.1_Linux_x86_64 && \
wget https://github.com/timescale/timescaledb-backup/releases/download/0.1.1/ts-restore_0.1.1_Linux_x86_64 && \
# Check the checksums for the downloaded binaries
wget https://github.com/timescale/timescaledb-backup/releases/download/0.1.1/checksums.txt && \
cat checksums.txt && \
sha256sum ts-dump_0.1.1_Linux_x86_64 && \
sha256sum ts-restore_0.1.1_Linux_x86_64 && \
# Rename the downloaded binaries to be the default binaries with generic names
mv ts-dump_0.1.1_Linux_x86_64 ts-dump && \
mv ts-restore_0.1.1_Linux_x86_64 ts-restore && \
# Make the downloaded binaries executable
chmod +x ts-dump ts-restore
Related to the documentation: https://github.com/timescale/docs/issues/629#issue-1067336521
What worked for me on Ubuntu (20.04):
# Get the files
go get github.com/timescale/timescaledb-backup/
# Build and "install" ts-dump
cd ~/go/src/github.com/timescale/timescaledb-backup/cmd/ts-dump
go build
sudo mv ts-dump /usr/share/
# Build and "install" ts-restore
cd ~/go/src/github.com/timescale/timescaledb-backup/cmd/ts-restore
go build
sudo mv ts-restore /usr/share/
After this, both commands were available to the necessary users.
#49