Skip to content

Commit a632980

Browse files
Merge pull request #6336 from mailcow/staging
Update 2025-02
2 parents 2d1ef41 + 5296085 commit a632980

File tree

2 files changed

+9
-43
lines changed

2 files changed

+9
-43
lines changed

helper-scripts/_cold-standby.sh

-40
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,6 @@ echo "If this script is run automatically by cron or a timer AND you are using b
1010
echo "The snapshots of your backup destination should run AFTER the cold standby script finished to ensure consistent snapshots."
1111
echo
1212

13-
function docker_garbage() {
14-
IMGS_TO_DELETE=()
15-
16-
for container in $(grep -oP "image: \Kmailcow.+" docker-compose.yml); do
17-
18-
REPOSITORY=${container/:*}
19-
TAG=${container/*:}
20-
V_MAIN=${container/*.}
21-
V_SUB=${container/*.}
22-
EXISTING_TAGS=$(docker images | grep ${REPOSITORY} | awk '{ print $2 }')
23-
24-
for existing_tag in ${EXISTING_TAGS[@]}; do
25-
26-
V_MAIN_EXISTING=${existing_tag/*.}
27-
V_SUB_EXISTING=${existing_tag/*.}
28-
29-
# Not an integer
30-
[[ ! ${V_MAIN_EXISTING} =~ ^[0-9]+$ ]] && continue
31-
[[ ! ${V_SUB_EXISTING} =~ ^[0-9]+$ ]] && continue
32-
33-
if [[ ${V_MAIN_EXISTING} == "latest" ]]; then
34-
echo "Found deprecated label \"latest\" for repository ${REPOSITORY}, it should be deleted."
35-
IMGS_TO_DELETE+=(${REPOSITORY}:${existing_tag})
36-
elif [[ ${V_MAIN_EXISTING} -lt ${V_MAIN} ]]; then
37-
echo "Found tag ${existing_tag} for ${REPOSITORY}, which is older than the current tag ${TAG} and should be deleted."
38-
IMGS_TO_DELETE+=(${REPOSITORY}:${existing_tag})
39-
elif [[ ${V_SUB_EXISTING} -lt ${V_SUB} ]]; then
40-
echo "Found tag ${existing_tag} for ${REPOSITORY}, which is older than the current tag ${TAG} and should be deleted."
41-
IMGS_TO_DELETE+=(${REPOSITORY}:${existing_tag})
42-
fi
43-
44-
done
45-
46-
done
47-
48-
if [[ ! -z ${IMGS_TO_DELETE[*]} ]]; then
49-
docker rmi ${IMGS_TO_DELETE[*]}
50-
fi
51-
}
52-
5313
function preflight_local_checks() {
5414
if [[ -z "${REMOTE_SSH_KEY}" ]]; then
5515
>&2 echo -e "\e[31mREMOTE_SSH_KEY is not set\e[0m"

update.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ docker_garbage() {
3636
IMGS_TO_DELETE=()
3737

3838
declare -A IMAGES_INFO
39-
COMPOSE_IMAGES=($(grep -oP "image: \Kmailcow.+" "${SCRIPT_DIR}/docker-compose.yml"))
39+
COMPOSE_IMAGES=($(grep -oP "image: \K(ghcr\.io/)?mailcow.+" "${SCRIPT_DIR}/docker-compose.yml"))
4040

41-
for existing_image in $(docker images --format "{{.ID}}:{{.Repository}}:{{.Tag}}" | grep 'mailcow/'); do
41+
for existing_image in $(docker images --format "{{.ID}}:{{.Repository}}:{{.Tag}}" | grep -E '(mailcow/|ghcr\.io/mailcow/)'); do
4242
ID=$(echo "$existing_image" | cut -d ':' -f 1)
4343
REPOSITORY=$(echo "$existing_image" | cut -d ':' -f 2)
4444
TAG=$(echo "$existing_image" | cut -d ':' -f 3)
4545

46+
if [[ "$REPOSITORY" == "mailcow/backup" || "$REPOSITORY" == "ghcr.io/mailcow/backup" ]]; then
47+
if [[ "$TAG" != "<none>" ]]; then
48+
continue
49+
fi
50+
fi
51+
4652
if [[ " ${COMPOSE_IMAGES[@]} " =~ " ${REPOSITORY}:${TAG} " ]]; then
4753
continue
4854
else
@@ -57,7 +63,7 @@ docker_garbage() {
5763
echo " ${IMAGES_INFO[$id]} ($id)"
5864
done
5965

60-
if [ ! $FORCE ]; then
66+
if [ -z "$FORCE" ]; then
6167
read -r -p "Do you want to delete them to free up some space? [y/N] " response
6268
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
6369
docker rmi ${IMGS_TO_DELETE[*]}

0 commit comments

Comments
 (0)