Skip to content

Commit

Permalink
Error when restoring compressed WALs with Python 2
Browse files Browse the repository at this point in the history
Detects when barman-cloud-wal-restore is attempting to restore a
compressed WAL on python 2.x and returns an error message telling
the user to upgrade to a supported python 3.x.

See issue #325
  • Loading branch information
mikewallace1979 committed Aug 4, 2021
1 parent df80f8b commit 3e1087f
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 3e1087f

Please sign in to comment.