Object size.

This commit is contained in:
Alex Manning 2023-10-24 19:36:14 +01:00
parent e7749d226f
commit 3c5ef98636
2 changed files with 9 additions and 8 deletions

View file

@ -1,5 +1,5 @@
name: "Minio Backup"
version: "0.0.7"
version: "0.0.8"
slug: minio-backup
description: >-
"Backup the backup folder using minio."

View file

@ -42,17 +42,18 @@ def main():
backup_files = list(backup_folder.iterdir())
logger.info("Found the folllowing files in /backup: %s", backup_files)
objects = client.list_objects(config["minio_bucket"])
object_names = [x.object_name for x in objects]
logger.info("Found the following files in s3: %s", object_names)
objects = {x.object_name: x for x in client.list_objects(config["minio_bucket"])}
logger.info("Found the following files in s3: %s", objects.keys())
to_upload = []
for file in backup_files:
if file.name in object_names:
logger.info("File %s already exists in s3", file.name)
continue
else:
if file.name not in objects.keys():
to_upload.append(file)
else:
obj = objects[file.name]
logger.info("File %s already exists in s3", file.name)
logger.info("s3_size", obj.size)
logger.info("local_size", file.stat().st_size)
logger.warning(
"The following files do not already exist and will be backed up: %s", to_upload