MCPcopy Create free account
hub / github.com/wal-e/wal-e / wal_archive

Method wal_archive

wal_e/operator/backup.py:248–291  ·  view source on GitHub ↗

Uploads a WAL file to S3 or Windows Azure Blob Service This code is intended to typically be called from Postgres's archive_command feature.

(self, wal_path, concurrency=1)

Source from the content-addressed store, hash-verified

246 raise UserCritical('could not complete backup process')
247
248 def wal_archive(self, wal_path, concurrency=1):
249 """
250 Uploads a WAL file to S3 or Windows Azure Blob Service
251
252 This code is intended to typically be called from Postgres's
253 archive_command feature.
254 """
255
256 # Upload the segment expressly indicated. It's special
257 # relative to other uploads when parallel wal-push is enabled,
258 # in that it's not desirable to tweak its .ready/.done files
259 # in archive_status.
260 xlog_dir = os.path.dirname(wal_path)
261 segment = WalSegment(wal_path, explicit=True)
262 uploader = WalUploader(self.layout, self.creds, self.gpg_key_id)
263 group = WalTransferGroup(uploader)
264 group.start(segment)
265
266 # Upload any additional wal segments up to the specified
267 # concurrency by scanning the Postgres archive_status
268 # directory.
269 started = 1
270 seg_stream = WalSegment.from_ready_archive_status(xlog_dir)
271 while started < concurrency:
272 try:
273 other_segment = next(seg_stream)
274 except StopIteration:
275 break
276
277 if other_segment.path != wal_path:
278 group.start(other_segment)
279 started += 1
280
281 try:
282 # Wait for uploads to finish.
283 group.join()
284 except EnvironmentError as e:
285 if e.errno == errno.ENOENT:
286 print(e)
287 raise UserException(
288 msg='could not find file for wal-push',
289 detail=('The operating system reported: {0} {1}'
290 .format(e.strerror, repr(e.filename))))
291 raise
292
293 def wal_restore(self, wal_name, wal_destination, prefetch_max):
294 """

Callers 1

mainFunction · 0.80

Calls 8

startMethod · 0.95
joinMethod · 0.95
WalSegmentClass · 0.90
WalUploaderClass · 0.90
WalTransferGroupClass · 0.90
UserExceptionClass · 0.90
formatMethod · 0.80

Tested by

no test coverage detected