Skip to content

Commit

Permalink
fix: replace obs to boto3
Browse files Browse the repository at this point in the history
  • Loading branch information
Karina5005 committed Oct 17, 2023
1 parent 7b7c2ca commit ec6e743
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backup_github/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from pathlib import Path

from obs import ObsClient
import boto3 as boto3


def save_json(path, content):
Expand Down Expand Up @@ -56,19 +56,19 @@ def count_sizes(output_dir):


def upload_to_s3(ak, sk, endpoint, backup_dir, bucket, organization):
obs = ObsClient(
access_key_id=ak,
secret_access_key=sk,
server=endpoint,
path_style=True,
signature="v2",
is_signature_negotiation=True,
session = boto3.session.Session()
s3 = session.client(
service_name='s3',
aws_access_key_id=ak,
aws_secret_access_key=sk,
endpoint_url=endpoint,
verify=False
)
shutil.make_archive(base_name="backup_archive", format="gztar", root_dir=backup_dir)
resp = obs.putFile(
resp = s3.upload_file(
"./backup_archive.tar.gz",
bucket,
f'{organization}-{datetime.now().strftime("%m-%d-%Y_%H-%M")}.tar.gz',
"./backup_archive.tar.gz",
)
if resp.status >= 300:
logging.error(f"Uploading of backup failed, error message: {resp.errorMessage}")
Expand Down

0 comments on commit ec6e743

Please sign in to comment.