Lay groundwork for checking size in s3 is right.

This commit is contained in:
Alex Manning 2023-10-24 18:50:17 +01:00
parent 0a7f40c8d0
commit e7749d226f
2 changed files with 12 additions and 4 deletions

View file

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

View file

@ -42,10 +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 = [x.object_name for x in client.list_objects(config["minio_bucket"])] objects = client.list_objects(config["minio_bucket"])
logger.info("Found the following files in s3: %s", objects) object_names = [x.object_name for x in objects]
logger.info("Found the following files in s3: %s", object_names)
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:
to_upload.append(file)
to_upload = [x for x in backup_folder.iterdir() if x.name not in objects]
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
) )