maxakuru / git-backup

Sync files/folders to git repositories, schedule with Docker image

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-backup

Docker Image Version (latest by date) Publish Test

🚨 Git is not designed to serve as a backup tool.

..but this does it anyway. Backup files/folders to a git repo. Run on a cron schedule or repeated loop with delay. Archive files/folders and set specific destinations in remote repository. Use Git LFS or chunking for oversized files.

Install

With Docker

docker pull maxakuru/git-backup
docker run -it --rm \
    -v $PWD/config:/backup/config \
    -v $PWD/repos:/backup/repos \
    -v $PWD/secrets:/backup/secrets \
    -e REPO_NAME=<REPO_NAME> \
    -e REPO_OWNER=<GIT_OWNER> \
    -e GIT_TOKEN=<GIT_PATOKEN> \
    -e PATHS=local/path/one:remote/path/one,local/path/two:remote/path/two \
    -e LOOP=<false|true> \
    -e LOOP_INTERVAL=<minutes (float)> \
    -e LOOP_SCHEDULE=<crontab expression (string)> \
    -e COMPRESS=<zip|tar|gztar|bztar|xztar|true|false> \
    -e SAVE_CONFIG=<bool> \
    -e SAVE_SECRETS=<bool> \
    -e GIT_ADD=<bool> \
    -e GIT_COMMIT=<bool> \
    -e GIT_PUSH=<bool> \
    -e GIT_MESSAGE=<string> \
    -e GIT_EMAIL=<string> \
    -e GIT_NAME=<string> \
    -e LOG_LEVEL=<0|1|2|3|4|5> \
    maxakuru/git-backup

With Docker Compose

# docker-compose.yaml
backup:
    container_name: backup
    image: maxakuru/git-backup:latest
    restart: always
    environment:
        - REPO_NAME=<REPO_NAME>
        - REPO_OWNER=<REPO_OWNER>
        - GIT_TOKEN=<GIT_TOKEN>
        # - ... see above

Dev

Run with local changes

docker run -it --rm -v $PWD/volume:/backup/config \
    -v $PWD/git_backup:/backup/git_backup \
    -e REPO_NAME=<REPO_NAME> \
    -e REPO_OWNER=<REPO_OWNER> \
    -e GIT_TOKEN=<GIT_TOKEN> \
    -e PATHS=<PATHS> \
    maxakuru/git-backup:dev

Test

echo "MY_GITHUB_TOKEN=<GITHUB_PAT> >> .env"
./test/functional/test.sh

Build

docker build -t maxakuru/git-backup:dev .

Run

docker run -it --rm -v $PWD/volume:/backup/config \
    -e REPO_NAME=<REPO_NAME> \
    -e REPO_OWNER=<REPO_OWNER> \
    -e GIT_TOKEN=<GIT_TOKEN> \
    -e PATHS=<PATHS> \
    maxakuru/git-backup:dev

Open shell

docker run -it --rm -e="CLI=true" -v $PWD/volume:/backup/config maxakuru/git-backup:dev /bin/bash

About

Sync files/folders to git repositories, schedule with Docker image


Languages

Language:Python 91.9%Language:Shell 6.9%Language:Dockerfile 1.2%