Răsfoiți Sursa

docker: support adding extra options to backup command (#7060)

Co-authored-by: Joe Chen <[email protected]>
liuxhit 2 ani în urmă
părinte
comite
05a6a9d6e9
3 a modificat fișierele cu 17 adăugiri și 1 ștergeri
  1. 1 0
      CHANGELOG.md
  2. 8 0
      docker/README.md
  3. 8 1
      docker/runtime/backup-job.sh

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@ All notable changes to Gogs are documented in this file.
 - New configuration option `[server] SSH_SERVER_MACS` for setting list of accepted MACs for connections to builtin SSH server. [#6434](https://github.com/gogs/gogs/issues/6434)
 - Support specifying custom schema for PostgreSQL. [#6695](https://github.com/gogs/gogs/pull/6695)
 - Support rendering Mermaid diagrams in Markdown. [#6776](https://github.com/gogs/gogs/pull/6776)
+- Docker: Allow passing extra arguments to the `backup` command. [#7060](https://github.com/gogs/gogs/pull/7060)
 - New languages support: Mongolian, Romanian. [#6510](https://github.com/gogs/gogs/pull/6510) [#7082](https://github.com/gogs/gogs/pull/7082)
 
 ### Changed

+ 8 - 0
docker/README.md

@@ -120,6 +120,14 @@ This container has some options available via environment variables, these optio
   - <u>Action:</u>
       Used by backup system. If defined, supplies `--exclude-repos` argument to `gogs backup`.\
       See: [Backup System](#backup-system)
+- **BACKUP_EXTRA_ARGS**:
+  - <u>Possible value:</u>
+      `--verbose --exclude-mirror-repos`
+  - <u>Default:</u>
+      `null`
+  - <u>Action:</u>
+      Used by backup system. If defined, append content to arguments to `gogs backup`.\
+      See: [Backup System](#backup-system)
 
 ## Backup system
 

+ 8 - 1
docker/runtime/backup-job.sh

@@ -4,6 +4,7 @@ execute_backup_job() {
 	BACKUP_ARG_PATH="${1:-}"
 	BACKUP_ARG_CONFIG="${BACKUP_ARG_CONFIG:-}"
 	BACKUP_ARG_EXCLUDE_REPOS="${BACKUP_ARG_EXCLUDE_REPOS:-}"
+	BACKUP_EXTRA_ARGS="${BACKUP_EXTRA_ARGS:-}"
 	cd "/app/gogs" || exit 1
 
 	BACKUP_ARGS="--target=${BACKUP_ARG_PATH}"
@@ -16,7 +17,13 @@ execute_backup_job() {
 		BACKUP_ARGS="${BACKUP_ARGS} --exclude-repos=${BACKUP_ARG_EXCLUDE_REPOS}"
 	fi
 
-	./gogs backup "${BACKUP_ARGS}" || echo "Error: Backup job returned non-successful code." && exit 1
+	if [ -n "${BACKUP_EXTRA_ARGS}" ]; then
+		BACKUP_ARGS="${BACKUP_ARGS} ${BACKUP_EXTRA_ARGS}"
+	fi
+
+	# NOTE: We actually need word splitting to be able to pass multiple arguments.
+	# shellcheck disable=SC2086
+	./gogs backup ${BACKUP_ARGS} || echo "Error: Backup job returned non-successful code." && exit 1
 }
 
 main() {