Compare commits
12 Commits
cd553879a2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cd6e11fe48 | |||
| 1de35afed2 | |||
| d23d6e0b42 | |||
| 3389c0a35a | |||
| 4b4624afc8 | |||
| 19628bc774 | |||
| f02154bfd3 | |||
| baa8c6b9a4 | |||
| 615e3989fb | |||
| 10295e2f21 | |||
| 349e4d43be | |||
| 22b1f374af |
34
.gitea/workflows/local-docker.yaml
Normal file
34
.gitea/workflows/local-docker.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
name: Push to local registry
|
||||||
|
run-name: ${{ gitea.actor }} is pushing -> local Docker
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build and push image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.likemath.ru
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: gitea.likemath.ru/alex/s3-mirror:latest
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -159,4 +159,3 @@ cython_debug/
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.12.0
|
rev: 24.10.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: [--line-length=88, --target-version=py38]
|
args: [--line-length=88, --target-version=py38]
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.9.2
|
rev: 7.1.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
args: # arguments to configure flake8
|
args: # arguments to configure flake8
|
||||||
@@ -20,7 +20,7 @@ repos:
|
|||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: check-json
|
- id: check-json
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.10.1
|
rev: 5.13.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: ["--filter-files" ]
|
args: ["--filter-files" ]
|
||||||
|
|||||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
FROM docker.io/python:3.12-slim as builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
|
COPY *.py /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["python3", "main.py"]
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
# s3-mirror
|
# s3-mirror
|
||||||
|
|
||||||
Full mirroring between two s3-targets with redundant files removing.
|
Full mirroring between two s3-targets with redundant files removing.
|
||||||
|
|
||||||
|
## Example with Docker
|
||||||
|
```
|
||||||
|
docker build . -t s3-mirror
|
||||||
|
podman run -v ~/.mcli/config.json:/root/.mc/config.json:ro --rm s3-mirror
|
||||||
|
```
|
||||||
|
|||||||
9
main.py
9
main.py
@@ -153,7 +153,14 @@ def main():
|
|||||||
for file_to_remove in redundant:
|
for file_to_remove in redundant:
|
||||||
object_name = os.path.join(target_prefix, file_to_remove)
|
object_name = os.path.join(target_prefix, file_to_remove)
|
||||||
logging.info(f"Removing redundant {target_bucket}:{object_name}")
|
logging.info(f"Removing redundant {target_bucket}:{object_name}")
|
||||||
target_s3.remove_object(bucket_name="backups", object_name=object_name)
|
try:
|
||||||
|
target_s3.remove_object(
|
||||||
|
bucket_name=target_bucket, object_name=object_name
|
||||||
|
)
|
||||||
|
except Exception as err:
|
||||||
|
print(
|
||||||
|
f"Unable to remove {target_bucket}/{object_name}: erorr {err}"
|
||||||
|
)
|
||||||
del target_files[file_to_remove]
|
del target_files[file_to_remove]
|
||||||
print(f"Removed {len(redundant)} files")
|
print(f"Removed {len(redundant)} files")
|
||||||
print(f"Target after removing redundant {get_file_metrics(target_files)}")
|
print(f"Target after removing redundant {get_file_metrics(target_files)}")
|
||||||
|
|||||||
Reference in New Issue
Block a user