weak-head / nimbus

Nimbus is engineered to optimize data backup processes and efficiently orchestrate service deployments for homelabs and dev environments.
MIT License
1 stars 0 forks source link

Add tar archival format that doesn't depend on external utilities #1

Closed weak-head closed 4 months ago

weak-head commented 4 months ago

Description

As of now only rar is supported as archival format, this introduces a necessity of having an external 3rd-party dependency. A python native tar format should be supported, so backups and uploads could work out of the box.

Implementation Example

Using tarfile library.

import tarfile
import os

def create_tar_archive(source_folder, output_tar):
    with tarfile.open(output_tar, 'w') as tar:
        for root, _, files in os.walk(source_folder):
            for file in files:
                file_path = os.path.join(root, file)
                arcname = os.path.relpath(file_path, source_folder)
                tar.add(file_path, arcname=arcname)

# Usage
source_folder_path = '/path/to/source/folder'
output_tar_path = '/path/to/output/archive.tar'

create_tar_archive(source_folder_path, output_tar_path)
print(f"Archive created at: {output_tar_path}")

Configuration changes

Support the following archive providers:

profiles:
  archive:
    - name: tar_default
      provider: tar
    - name: tar_gz
      provider: tar.gz
    - name: tar_bz2
      provider: tar.bz2