OriolFilter 22b5f7cdd7 upload
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00
2022-01-16 17:29:42 +01:00

Usage

  1. Mount the folders/files you want to push into a repository in the /GIT_DIR directory.
  2. Finally, set the environment variables required.
  3. Optional, configure crontab to have periodical push in case you want to use it as a backup (ie. factorio server public world backups).

Notes

In case of wanting to push the content of a directory, just mount it as /GIT_DIR

usage?

Use a env file with a simple env config

GIT_REPO_URL=https://gitserver.url/user/repo_name.git
GIT_USERNAME=username
GIT_PASSWORD=TOKEN (or password...)
GIT_REMOTE_BRANCH=dev
GIT_FORCE_PUSH=yes
_time=`date "+%Y-%M-%d"` &&  \
docker run -v "$(pwd)/folder_to_push:/GIT_DIR" -e GIT_COMMIT_MESSAGE="Commit done at $_time" --env-file env.file -it testing/git_backup:latest

In this scenario we are storing the required information to push in a env file

Git ignore

Is as simple to create a .gitignore file and place it in the folder that you want to back up.

In case of .gitignore being inside the folder to push

# .gitignore
ignored_file
docker run -v "$(pwd)/folder_to_push:/GIT_DIR" -e GIT_COMMIT_MESSAGE="Commit done at $_time" --env-file env.file -it testing/git_backup:latest

In case of having to push multiple directories/files

docker run -v "/path_to/file_to_push1:/GIT_DIR/file_to_push1"  "/path_to/file_to_push2:/GIT_DIR/file_to_push2"  "/path_to/gitignore:/GIT_DIR/.gitignore" -e GIT_COMMIT_MESSAGE="Commit done at $_time" --env-file env.file -it testing/git_backup:latest

Environment

Configurable

ENV DEFAULT value DESCRIPTION
GIT_REPO_URL Url from the repository
GIT_USERNAME Username or email from the git server
GIT_PASSWORD Token (or password, which is not recommended) from the git server
GIT_FORCE_PUSH Used to force the push, to enable it add any content
GIT_REMOTE_BRANCH master Branch to push
GIT_COMMIT_MESSAGE . Message used during the commit
GIT_COMMIT_AUTHOR On empty will use "Name"
GIT_COMMIT_EMAIL On empty will commit as "<>"
--- --- ---
SKIP_SSL_CHECK --- disabled
GIT_TAG --- disabled
GIT_TAG_MESSAGE --- disabled
TAR_CONTENT --- disabled

--- means that it's empty

Not Configurable

This exists as a documentation
ENV DEFAULT DESCRIPTION
__CREDENTIAL_HELPER_SCRIPT_PATH /scripts/credential_helper.sh" Points to the script used to automate git authentication (credential manager)

Docker compose

...

Description
Script to push a repository using bash and/or docker
Readme 23 KiB
Languages
Shell 75.1%
Dockerfile 24.9%