Browse Source

Update backup-volumes.py

master
Sean Johnson 2 years ago
parent
commit
d02117927c
  1. 10
      resource/tools/backup-volumes.py

10
resource/tools/backup-volumes.py

@ -22,12 +22,12 @@ KEEP_LAST_SNAPSHOTS = int(os.getenv("KEEP_LAST_SNAPSHOTS", 7))
ONLY_MATCHING = re.compile(os.getenv("ONLY_MATCHING", r"^.*$"))
def timestamp_sec() -> str:
def timestamp_filename() -> str:
return datetime.now().strftime("%Y-%m-%dT%H-%M-%SZ%z")
def timestamp_micros() -> str:
return datetime.now().strftime("%Y-%m-%dT%H-%M-%S.%fZ%z")
def timestamp_log() -> str:
return datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ%z")
def chunked_iter(items: Sequence, size: int) -> Iterator[List[List]]:
@ -43,7 +43,7 @@ def chunked_iter(items: Sequence, size: int) -> Iterator[List[List]]:
def log_stdout(message, exception: Optional[Exception] = None, **context):
message = {
"timestamp": timestamp_micros(),
"timestamp": timestamp_log(),
"message": message,
"context": context,
}
@ -124,7 +124,7 @@ async def backup_volume(vol_name: str, vol_data: str):
async def perform_volume_snapshot(vol_name: str, vol_data: dict):
# Make a new snapshot
snapshot_name = f"{vol_name}-{timestamp_sec()}"
snapshot_name = f"{vol_name}-{timestamp_filename()}"
await get_proc_response(await convoy(
"snapshot", "create", vol_name, "--name", snapshot_name,
), json_decode=False)

Loading…
Cancel
Save