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" name: "Minio Backup"
version: "0.0.7" version: "0.0.8"
slug: minio-backup slug: minio-backup
description: >- description: >-
"Backup the backup folder using minio." "Backup the backup folder using minio."

View file

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