Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qocument compression issues with barman-cloud-wal-archive and older python versions #369

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions barman/clients/cloud_walarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@ def parse_arguments(args=None):
compression.add_argument(
"-z",
"--gzip",
help="gzip-compress the WAL while uploading to the cloud",
help="gzip-compress the WAL while uploading to the cloud "
"(should not be used with python < 3.2)",
action="store_const",
const="gzip",
dest="compression",
)
compression.add_argument(
"-j",
"--bzip2",
help="bzip2-compress the WAL while uploading to the cloud",
help="bzip2-compress the WAL while uploading to the cloud "
"(should not be used with python < 3.3)",
action="store_const",
const="bzip2",
dest="compression",
Expand Down
8 changes: 8 additions & 0 deletions barman/clients/cloud_walrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

import logging
import os
import sys
from contextlib import closing

import barman
from barman.cloud import configure_logging
from barman.cloud_providers import get_cloud_interface
from barman.exceptions import BarmanException
from barman.utils import force_str
from barman.xlog import hash_dir, is_any_xlog_file, is_backup_file

Expand Down Expand Up @@ -232,6 +234,12 @@ def download_wal(self, wal_name, wal_dest):
)
raise SystemExit(1)

if compression and sys.version_info < (3, 0, 0):
raise BarmanException(
"Compressed WALs cannot be restored with Python 2.x - "
"please upgrade to a supported version of Python 3"
)

# Download the file
logging.debug(
"Downloading %s to %s (%s)",
Expand Down
16 changes: 10 additions & 6 deletions doc/barman-cloud-wal-archive.1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ This script can be used in the \f[C]archive_command\f[] of a PostgreSQL
server to ship WAL files to the Cloud.
Currently AWS S3 and Azure Blob Storage are supported.
.PP
Note: If you are running python 2 or older unsupported versions of
python 3 then avoid the compression options \f[C]--gzip\f[R] or
\f[C]--bzip2\f[R] as barman-cloud-wal-restore is unable to restore
gzip-compressed WALs on python < 3.2 or bzip2-compressed WALs on python
< 3.3.
.PP
This script and Barman are administration tools for disaster recovery of
PostgreSQL servers written in Python and maintained by EnterpriseDB.
.SH POSITIONAL ARGUMENTS
Expand Down Expand Up @@ -64,14 +70,12 @@ test connectivity to the cloud destination and exit
.RE
.TP
.B \-z, \[en]gzip
gzip\-compress the WAL while uploading to the cloud
.RS
.RE
gzip-compress the WAL while uploading to the cloud (should not be used
with python < 3.2)
.TP
.B \-j, \[en]bzip2
bzip2\-compress the WAL while uploading to the cloud
.RS
.RE
bzip2-compress the WAL while uploading to the cloud (should not be used
with python < 3.3)
.TP
.B \[en]cloud\-provider {aws\-s3,azure\-blob\-storage}
the cloud provider to which the backup should be uploaded
Expand Down
7 changes: 7 additions & 0 deletions doc/barman-cloud-wal-archive.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ This script can be used in the `archive_command` of a PostgreSQL
server to ship WAL files to the Cloud. Currently AWS S3 and Azure Blob
Storage are supported.

Note: If you are running python 2 or older unsupported versions of
python 3 then avoid the compression options `--gzip` or `--bzip2` as
barman-cloud-wal-restore is unable to restore gzip-compressed WALs
on python < 3.2 or bzip2-compressed WALs on python < 3.3.

This script and Barman are administration tools for disaster recovery
of PostgreSQL servers written in Python and maintained by EnterpriseDB.

Expand Down Expand Up @@ -55,9 +60,11 @@ WAL_PATH

-z, --gzip
: gzip-compress the WAL while uploading to the cloud
(should not be used with python < 3.2)

-j, --bzip2
: bzip2-compress the WAL while uploading to the cloud
(should not be used with python < 3.3)

--cloud-provider {aws-s3,azure-blob-storage}
: the cloud provider to which the backup should be uploaded
Expand Down
7 changes: 6 additions & 1 deletion doc/manual/55-barman-cli.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ and can be installed alongside the PostgreSQL server:
- `barman-cloud-restore`: script to be used to restore a backup directly
taken with `barman-cloud-backup` from an S3 object store;

For information on how to setup credentials for the Cloud utilities,
For information on how to setup credentials for the aws-s3 cloud provider
please refer to the ["Credentials" section in Boto 3 documentation][boto3creds].

For credentials for the azure-blob-storage cloud provider see the
["Environment variables for authorization parameters" section in the Azure documentation][azure-storage-auth].
The following environment variables are supported: `AZURE_STORAGE_CONNECTION_STRING`,
`AZURE_STORAGE_KEY` and `AZURE_STORAGE_SAS_TOKEN`.

> **WARNING:** Cloud utilities require the appropriate library for the cloud
> provider you wish to use - either: [boto3][boto3] or
> [azure-storage-blob][azure-storage-blob] and (optionally)
Expand Down
1 change: 1 addition & 0 deletions doc/manual/99-references.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
[boto3creds]: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html
[azure-identity]: https://docs.microsoft.com/en-us/python/api/azure-identity/?view=azure-python
[azure-storage-blob]: https://docs.microsoft.com/en-us/python/api/azure-storage-blob/?view=azure-python
[azure-storage-auth]: https://docs.microsoft.com/en-us/azure/storage/blobs/authorize-data-operations-cli#set-environment-variables-for-authorization-parameters


[3]: http://github.com/EnterpriseDB/barman
Expand Down