Compare commits

..

25 Commits

Author SHA1 Message Date
mag37
ef0198871c colored backup removal message 2025-12-10 18:29:29 +01:00
mag37
6b3c2680d4 typo fixes 2025-12-10 18:22:07 +01:00
mag37
56d0229d6d added dynamic phrasing to backup removal 2025-12-10 18:15:44 +01:00
mag37
85ebb0e715 made a function out of the backup removal to be more modular 2025-12-08 15:17:45 +01:00
mag37
260280f96d Moved the backup - cleanup to always trigger if -b option is usd. Added -p&-b warning. 2025-12-07 18:42:25 +01:00
mag37
3fb2cc2d05 Changed from -k DaysKept -> -b BackupForDays + some readme tweaks 2025-12-07 09:52:58 +01:00
mag37
c931b16eab changed the RepoDigests grab and logic 2025-12-06 16:56:23 +01:00
mag37
7493d462b3 Patched bugfix to not recreate stopped containers 2025-12-04 11:07:42 +01:00
mag37
ed2938166f readme tweaks + added help for -K option 2025-12-04 10:36:13 +01:00
mag37
49403b98a1 added function to print currently backed up images 2025-12-04 10:20:12 +01:00
mag37
f16953a479 Added all readme, help text and configs 2025-12-04 10:14:24 +01:00
mag37
160f4a2c5f Test to remove the <none>-tagged copy after backup is created 2025-11-29 17:06:06 +01:00
mag37
85e2b2c02c added timestamp variables to exports, formatting 2025-11-28 16:32:56 +01:00
mag37
644cbaedd1 moved the prune logic and made a forced prune with -k flag 2025-11-24 22:18:07 +01:00
mag37
eeb719296d cleaned up the config info queries 2025-11-24 22:07:25 +01:00
mag37
9c44a5176d fixed missing formatting variables 2025-11-22 20:22:57 +01:00
mag37
e191971933 label-fix to fallback to default :latest when unset 2025-11-21 14:03:32 +01:00
mag37
c3c7206622 quickfixes to not be completely broken - but needs much more work 2025-11-20 20:22:04 +01:00
mag37
c1124676d1 reworked the image listing when removing backups to properly list all dockcheck/*** backups 2025-11-15 20:53:45 +01:00
mag37
6576a36fda moved the cleanup and prune logic to always run. Changed some wording on messages. 2025-11-15 20:02:48 +01:00
mag37
42d35b7a03 enclosing some variables in braces due to strings messing up 2025-11-13 20:27:31 +01:00
mag37
fc58962f79 added forgotten variables, corrected some variables 2025-11-13 20:18:25 +01:00
mag37
ff2006437f final logic to get image backups to work for testing 2025-11-13 17:49:52 +01:00
mag37
ac98e81172 datecheck function rewrite 2025-11-13 17:29:53 +01:00
mag37
6fefcbc3dd added new variables, options and setup 2025-11-13 16:30:46 +01:00
4 changed files with 11 additions and 40 deletions

View File

@@ -27,8 +27,6 @@ ___
- Backup an image before pulling a new version for easy rollback in case of breakage. - Backup an image before pulling a new version for easy rollback in case of breakage.
- Removes backed up images older than *N* days. - Removes backed up images older than *N* days.
- List currently backed up images with `-B`. - List currently backed up images with `-B`.
- Fixes:
- Bugfix for `-s` *Stopped* to not recreate stopped containers after update.
- **v0.7.4**: - **v0.7.4**:
- Added new option `-R`: - Added new option `-R`:
- Will skip container recreation after pulling images. - Will skip container recreation after pulling images.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.7.5" VERSION="v0.7.4"
# ChangeNotes: New option -b N to backup image before pulling for easy rollback. # ChangeNotes: New option -R to pull without recreation. Fixes: value too great error, legacy cleanups.
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@@ -582,25 +582,6 @@ if [[ -n "${GotUpdates:-}" ]]; then
NumberofUpdates="${#SelectedUpdates[@]}" NumberofUpdates="${#SelectedUpdates[@]}"
# TODO: move this to proper place + setup optarg etc.
# Digest log setup
LogDigestChanges="true"
LogPath="$ScriptWorkDir/updatelog"
if [[ -n "${LogDigestChanges}" ]]; then
LogStore=()
LogStore+=("$(printf "%-30s %s > %s\n" "IMAGE:TAG" "OLD DIGEST" "NEW DIGEST")")
fi
# TODO: move this to proper place
get_image_facts(){
ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}')
ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig")
[[ "$ContRepoDigests" == "null" ]] && ContRepoDigests=""
ContRepo=${ContImage%:*}
ContApp=${ContRepo#*/}
[[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest"
}
CurrentQue=0 CurrentQue=0
for i in "${SelectedUpdates[@]}"; do for i in "${SelectedUpdates[@]}"; do
((CurrentQue+=1)) ((CurrentQue+=1))
@@ -611,17 +592,19 @@ if [[ -n "${GotUpdates:-}" ]]; then
ContPath=$($jqbin -r '."Config"."Labels"."com.docker.compose.project.working_dir"' <<< "$ContConfig") ContPath=$($jqbin -r '."Config"."Labels"."com.docker.compose.project.working_dir"' <<< "$ContConfig")
[[ "$ContPath" == "null" ]] && ContPath="" [[ "$ContPath" == "null" ]] && ContPath=""
# Add new backup tag prior to pulling if option is set # Add new backup tag prior to pulling if option is set
if [[ -n "${BackupForDays:-}" ]]; then if [[ -n "${BackupForDays:-}" ]]; then
get_image_facts ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}')
ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig")
[[ "$ContRepoDigests" == "null" ]] && ContRepoDigests=""
ContRepo=${ContImage%:*}
ContApp=${ContRepo#*/}
[[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest"
BackupName="dockcheck/${ContApp}:${RunTimestamp}_${ContTag}" BackupName="dockcheck/${ContApp}:${RunTimestamp}_${ContTag}"
docker tag "$ImageId" "$BackupName" docker tag "$ImageId" "$BackupName"
printf "%b%s backed up as %s%b\n" "$c_teal" "$i" "$BackupName" "$c_reset" printf "%b%s backed up as %s%b\n" "$c_teal" "$i" "$BackupName" "$c_reset"
fi fi
[[ -n "${LogDigestChanges}" ]] && get_image_facts
# Checking if compose-values are empty - hence started with docker run # Checking if compose-values are empty - hence started with docker run
if [[ -z "$ContPath" ]]; then if [[ -z "$ContPath" ]]; then
if [[ "$DRunUp" == true ]]; then if [[ "$DRunUp" == true ]]; then
@@ -636,17 +619,12 @@ if [[ -n "${GotUpdates:-}" ]]; then
if docker pull "$ContImage"; then if docker pull "$ContImage"; then
# Removal of the <none>-tag image left behind from backup # Removal of the <none>-tag image left behind from backup
if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${BackupForDays:-}" ]]; then docker rmi "$ContRepoDigests"; fi if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${BackupForDays:-}" ]]; then docker rmi "$ContRepoDigests"; fi
if [[ -n "${LogDigestChanges}" ]]; then
NewDigest=$(docker image inspect "$ContImage" --format '{{index .RepoDigests 0 }}')
LogStore+=("$(printf "%-30s %s > %s\n" "$i:$ContTag" "$ContRepoDigests" "$NewDigest")")
fi
else else
printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1 printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1
fi fi
done done
printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset" printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset"
[[ -n "${LogDigestChanges}" ]] && { printf "%s\n" "${LogStore[@]}" > "${LogPath}_$(date +'%Y-%m-%d_%H%M')"; }
if [[ "$SkipRecreate" == true ]]; then if [[ "$SkipRecreate" == true ]]; then
printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset" printf "%bSkipping container recreation due to -R.%b\n" "$c_yellow" "$c_reset"

View File

@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_MATRIX_VERSION="v0.5" NOTIFY_MATRIX_VERSION="v0.4"
# #
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -29,7 +29,7 @@ trigger_matrix_notification() {
AccessToken="${!AccessTokenVar}" # e.g. MATRIX_ACCESS_TOKEN=token-value AccessToken="${!AccessTokenVar}" # e.g. MATRIX_ACCESS_TOKEN=token-value
RoomId="${!RoomIdVar}" # e.g. MATRIX_ROOM_ID=myroom RoomId="${!RoomIdVar}" # e.g. MATRIX_ROOM_ID=myroom
MatrixServer="${!MatrixServerVar}" # e.g. MATRIX_SERVER_URL=http://matrix.yourdomain.tld MatrixServer="${!MatrixServerVar}" # e.g. MATRIX_SERVER_URL=http://matrix.yourdomain.tld
MsgBody=$($jqbin -Rn --arg body "$MessageBody" '{msgtype:"m.text", body:$body}') MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
# URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx # URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx
curl -S -o /dev/null ${CurlArgs} -X POST "$MatrixServer/_matrix/client/r0/rooms/$RoomId/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody" curl -S -o /dev/null ${CurlArgs} -X POST "$MatrixServer/_matrix/client/r0/rooms/$RoomId/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"

View File

@@ -15,14 +15,12 @@ calibre https://github.com/linuxserver/docker-calibre/releases
calibre-web https://github.com/linuxserver/docker-calibre-web/releases calibre-web https://github.com/linuxserver/docker-calibre-web/releases
cleanuperr https://github.com/flmorg/cleanuperr/releases cleanuperr https://github.com/flmorg/cleanuperr/releases
cross-seed https://github.com/cross-seed/cross-seed/releases cross-seed https://github.com/cross-seed/cross-seed/releases
crowdsec https://github.com/crowdsecurity/crowdsec/releases
cup https://github.com/sergi0g/cup/releases cup https://github.com/sergi0g/cup/releases
dockge https://github.com/louislam/dockge/releases dockge https://github.com/louislam/dockge/releases
dozzle https://github.com/amir20/dozzle/releases dozzle https://github.com/amir20/dozzle/releases
flatnotes https://github.com/dullage/flatnotes/releases flatnotes https://github.com/dullage/flatnotes/releases
forgejo https://codeberg.org/forgejo/forgejo/releases forgejo https://codeberg.org/forgejo/forgejo/releases
fressrss https://github.com/FreshRSS/FreshRSS/releases fressrss https://github.com/FreshRSS/FreshRSS/releases
gerbil https://github.com/fosrl/gerbil/releases
gluetun https://github.com/qdm12/gluetun/releases gluetun https://github.com/qdm12/gluetun/releases
go2rtc https://github.com/AlexxIT/go2rtc/releases go2rtc https://github.com/AlexxIT/go2rtc/releases
gotify https://github.com/gotify/server/releases gotify https://github.com/gotify/server/releases
@@ -47,11 +45,9 @@ mealie https://github.com/mealie-recipes/mealie/releases
meilisearch https://github.com/meilisearch/meilisearch/releases meilisearch https://github.com/meilisearch/meilisearch/releases
monica https://github.com/monicahq/monica/releases monica https://github.com/monicahq/monica/releases
mqtt https://github.com/eclipse/mosquitto/tags mqtt https://github.com/eclipse/mosquitto/tags
newt https://github.com/fosrl/newt/releases
nextcloud-aio-mastercontainer https://github.com/nextcloud/all-in-one/releases nextcloud-aio-mastercontainer https://github.com/nextcloud/all-in-one/releases
nginx https://github.com/docker-library/official-images/blob/master/library/nginx nginx https://github.com/docker-library/official-images/blob/master/library/nginx
owncast https://github.com/owncast/owncast/releases owncast https://github.com/owncast/owncast/releases
pangolin https://github.com/fosrl/pangolin/releases
prowlarr https://github.com/Prowlarr/Prowlarr/releases prowlarr https://github.com/Prowlarr/Prowlarr/releases
prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases
qbittorrent https://www.qbittorrent.org/news qbittorrent https://www.qbittorrent.org/news
@@ -70,7 +66,6 @@ snappymail https://github.com/the-djmaze/snappymail/releases
sonarr https://github.com/Sonarr/Sonarr/releases/ sonarr https://github.com/Sonarr/Sonarr/releases/
sonarr-ls https://github.com/linuxserver/docker-sonarr/releases sonarr-ls https://github.com/linuxserver/docker-sonarr/releases
syncthing https://github.com/syncthing/syncthing/releases syncthing https://github.com/syncthing/syncthing/releases
tailscale https://github.com/tailscale/tailscale/releases
tautulli https://github.com/Tautulli/Tautulli/releases tautulli https://github.com/Tautulli/Tautulli/releases
thelounge https://github.com/thelounge/thelounge/releases thelounge https://github.com/thelounge/thelounge/releases
traefik https://github.com/traefik/traefik/releases traefik https://github.com/traefik/traefik/releases