Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

Douglas Hunley: pgBackRest 2.07 and macOS Mojave


pgBackRest 2.07 was announced today. As usual, I immediately downloaded it and tried to get it up and running on my MacBook (currently running Mojave). It wasn’t as straightforward as one might hope, and the online instructions assume a linux system, so I figured I’d write this up for anyone else attempting the same.

Since this is OSX, we have to do some work to make things right before we even start with the pgBackRest code. First up, get a real OpenSSL install. We’ll use Homebrew for this:

> brew install openssl [output snipped] > openssl version -a LibreSSL 2.6.4 built on: date not available platform: information not available options: bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx) compiler: information not available OPENSSLDIR: "/private/etc/ssl" > /usr/local/opt/openssl/bin/openssl version -a OpenSSL 1.0.2p 14 Aug 2018 built on: reproducible build, date unspecified platform: darwin64-x86_64-cc options: bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx) compiler: clang -I. -I.. -I../include -fPIC -fno-common -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM OPENSSLDIR: "/usr/local/etc/openssl"

As you can see, the default SSL from OSX is in /usr/bin while the newly installed OpenSSL is in /usr/local/opt/openssl . In my testing, this is enough to proceed with pgBackRest but I prefer to have the openssl binary match the libs and I’m a glutton for punishment, so I replace the OSX binary with the Homebrew one:

> sudo mv /usr/bin/openssl /usr/bin/openssl.old > sudo ln -s /usr/local/opt/openssl/bin/openssl /usr/bin > ls -ld /usr/bin/openssl* lrwxr-xr-x 1 root wheel 34 Nov 16 11:39 /usr/bin/openssl -> /usr/local/opt/openssl/bin/openssl* -rwxr-xr-x 1 root wheel 1.2M Sep 21 00:16 /usr/bin/openssl.old*

OK, so now we have an SSL that pgBackRest knows how to speak to. We need to install some Perl modules that it needs. If you haven’t run CPAN before, just accept the defaults when it asks you things:

> perl -MCPAN -e shell cpan[1]> install DBI [output snipped] cpan[2]> install DBD::Pg [output snipped] cpan[3]> install IO::Socket::SSL [output snipped] cpan[4]> install XML::LibXML [output snipped] cpan[5]> q

Now we’ve got our Perl modules installed, we have to tell our shell where to find them:

> export PERL5LIB=/Users/doug/perl5/lib/perl5 > export PERL_LOCAL_LIB_ROOT=/Users/doug/perl5 > export PERL_MB_OPT=--install_base "/Users/doug/perl5" > export PERL_MM_OPT=INSTALL_BASE=/Users/doug/perl5

Obviously, you will change ‘doug’ to your OSX username. You will also need to add these to your shell’s startup file ( .profile , .bash_profile , etc) to make them permanent.

Now, we can actually get down to the business of compiling and installing pgBackRest. Download the 2.07 tarball from the releases tab on GitHub, and let’s get busy:

> tar xvf Downloads/pgbackrest-release-2.07.tar.gz [output snipped] > cd pgbackrest-release-2.07

Now, we need to make some edits to the included Makefile. So vi src/Makefile and jump to line 42. Edit this line to be:

LDEXTRA = -L /usr/local/opt/openssl/lib

This tells the build process where to find the OpenSSL that we installed. Then, jump to line 149 and change it to:

install -m 755 pgbackrest $(DESTDIR)/usr/local/bin

This makes it install into /usr/local/bin which is where Homebrew puts everything else and you shouldn’t need to use sudo to write to it.

Now, compile and install it:

> make -s -C ./src && make -s -C ./src/install

Assuming that goes well, you can now run pgBackRest to verify it’s installed and functional:

> /usr/local/bin/pgbackrest pgBackRest 2.07 - General help Usage: pgbackrest [options] [command] Commands: archive-get Get a WAL segment from the archive. archive-push Push a WAL segment to the archive. backup Backup a database cluster. check Check the configuration. expire Expire backups that exceed retention. help Get help. info Retrieve information about backups. restore Restore a database cluster. stanza-create Create the required stanza data. stanza-delete Delete a stanza. stanza-upgrade Upgrade a stanza. start Allow pgBackRest processes to run. stop Stop pgBackRest processes from running. version Get version. Use 'pgbackrest help [command]' for more information.

You should now be able to follow the online docs and setup pgBackRest.


Viewing all articles
Browse latest Browse all 12749

Latest Images

Trending Articles

Latest Images