예제 #1
0
    def wal_s3_archive(self, wal_path):
        """
        Uploads a WAL file to S3

        This code is intended to typically be called from Postgres's
        archive_command feature.
        """
        wal_file_name = os.path.basename(wal_path)
        s3_url = '{0}/wal_{1}/{2}'.format(
            self.s3_prefix, FILE_STRUCTURE_VERSION, wal_file_name)

        logger.info(msg='begin archiving a file',
                    detail=('Uploading "{wal_path}" to "{s3_url}".'
                            .format(wal_path=wal_path, s3_url=s3_url)),
                    structured={'action': 'push-wal',
                                'key': s3_url,
                                'seg': wal_file_name,
                                'prefix': self.s3_prefix,
                                'state': 'begin'})

        # Upload and record the rate at which it happened.
        kib_per_second = s3_worker.do_lzop_s3_put(s3_url, wal_path,
                                                  self.gpg_key_id)

        logger.info(
            msg='completed archiving to a file ',
            detail=('Archiving to "{s3_url}" complete at '
                    '{kib_per_second}KiB/s. ')
            .format(s3_url=s3_url, kib_per_second=kib_per_second),
                    structured={'action': 'push-wal',
                                'key': s3_url,
                                'rate': kib_per_second,
                                'seg': wal_file_name,
                                'prefix': self.s3_prefix,
                                'state': 'complete'})
예제 #2
0
    def wal_s3_archive(self, wal_path):
        """
        Uploads a WAL file to S3

        This code is intended to typically be called from Postgres's
        archive_command feature.

        """
        wal_file_name = os.path.basename(wal_path)

        # It's okay-ish for this to blow up in event of problems:
        # Postgres will retry archiving *forever*
        s3_worker.do_lzop_s3_put(
            '{0}/wal_{1}/{2}'.format(self.s3_prefix,
                                     FILE_STRUCTURE_VERSION,
                                     wal_file_name),
            wal_path, self.gpg_key_id)
예제 #3
0
    def wal_s3_archive(self, wal_path):
        """
        Uploads a WAL file to S3

        This code is intended to typically be called from Postgres's
        archive_command feature.

        """
        wal_file_name = os.path.basename(wal_path)

        # It's okay-ish for this to blow up in event of problems:
        # Postgres will retry archiving *forever*
        s3_worker.do_lzop_s3_put(
            '{0}/wal_{1}/{2}'.format(self.s3_prefix,
                                     FILE_STRUCTURE_VERSION,
                                     wal_file_name),
            wal_path)
예제 #4
0
    def wal_s3_archive(self, wal_path):
        """
        Uploads a WAL file to S3

        This code is intended to typically be called from Postgres's
        archive_command feature.
        """
        wal_file_name = os.path.basename(wal_path)
        s3_url = "{0}/wal_{1}/{2}".format(self.s3_prefix, FILE_STRUCTURE_VERSION, wal_file_name)

        logger.info(
            msg="begin archiving a file",
            detail=('Uploading "{wal_path}" to "{s3_url}".'.format(wal_path=wal_path, s3_url=s3_url)),
            structured={
                "action": "push-wal",
                "key": s3_url,
                "seg": wal_file_name,
                "prefix": self.s3_prefix,
                "state": "begin",
            },
        )

        # Upload and record the rate at which it happened.
        kib_per_second = s3_worker.do_lzop_s3_put(s3_url, wal_path, self.gpg_key_id)

        logger.info(
            msg="completed archiving to a file ",
            detail=('Archiving to "{s3_url}" complete at ' "{kib_per_second}KiB/s. ").format(
                s3_url=s3_url, kib_per_second=kib_per_second
            ),
            structured={
                "action": "push-wal",
                "key": s3_url,
                "rate": kib_per_second,
                "seg": wal_file_name,
                "prefix": self.s3_prefix,
                "state": "complete",
            },
        )
예제 #5
0
    def wal_s3_archive(self, wal_path):
        """
        Uploads a WAL file to S3

        This code is intended to typically be called from Postgres's
        archive_command feature.
        """
        wal_file_name = os.path.basename(wal_path)
        s3_url = '{0}/wal_{1}/{2}'.format(self.s3_prefix,
                                          FILE_STRUCTURE_VERSION,
                                          wal_file_name)

        logger.info(msg='begin archiving a file',
                    detail=('Uploading "{wal_path}" to "{s3_url}".'.format(
                        wal_path=wal_path, s3_url=s3_url)),
                    structured={
                        'action': 'push-wal',
                        'key': s3_url,
                        'seg': wal_file_name,
                        'prefix': self.s3_prefix,
                        'state': 'begin'
                    })

        # Upload and record the rate at which it happened.
        kib_per_second = s3_worker.do_lzop_s3_put(s3_url, wal_path,
                                                  self.gpg_key_id)

        logger.info(msg='completed archiving to a file ',
                    detail=('Archiving to "{s3_url}" complete at '
                            '{kib_per_second}KiB/s. ').format(
                                s3_url=s3_url, kib_per_second=kib_per_second),
                    structured={
                        'action': 'push-wal',
                        'key': s3_url,
                        'rate': kib_per_second,
                        'seg': wal_file_name,
                        'prefix': self.s3_prefix,
                        'state': 'complete'
                    })