diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fcb871f81c683a1084ae84e34925290a2b10604f..e760372f6fff002f58af38f62f1498ab54e6b0bf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -186,15 +186,20 @@ build-spack-env-on-runner:
     - spack env create $SPACK_DEV_ENV spack.yaml
     - spack env activate $SPACK_DEV_ENV
     - spack concretize -f --fresh
-    - spack install -y --fresh --no-check-signature --keep-stage
+    - spack install -y -j2 --fresh --no-check-signature --keep-stage
   after_script:
+    - mkdir spack_logs
+    # succesfully installed packages: keep the spack logs for any package modified during this CI job
+    - cp --parents $SPACK_DEV_PATH/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0/*/.spack/*.txt ./
+    - mv .$SPACK_DEV_PATH/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0 spack_logs/installed
+    # not succesfully installed packages: also keep the spack logs for any packages that failed
     - cp --parents /tmp/$(whoami)/spack-stage/*/*.txt ./
-    - mv ./tmp/$(whoami)/spack-stage spack-logs
-  timeout: 2 days
+    - mv ./tmp/$(whoami)/spack-stage spack_logs/not_installed
   artifacts:
     paths:
-      - spack-logs
+      - spack_logs
     when: always
+  timeout: 2 days
   # cache:
   #   key: spack-cache-$CI_COMMIT_REF_SLUG
   #   paths:
@@ -238,16 +243,22 @@ sync-gitlab-spack-instance:
     - spack env activate $SPACK_NFS_ENV
     - cp $CI_PROJECT_DIR/spack.yaml $SPACK_ROOT/var/spack/environments/$SPACK_NFS_ENV/spack.yaml
     - spack concretize -f --fresh
-    - spack install -y --fresh --no-check-signature --keep-stage
+    - spack install -y -j2 --fresh --no-check-signature --keep-stage
     - spack module tcl refresh -y
     - spack reindex
     - spack env loads -r
   after_script:
+    - mkdir spack_logs
+    # succesfully installed packages: keep the spack logs for any package modified during this CI job
+    # (we use repo.yaml, that is modified at each start of the pipeline, as a reference file)
+    - find $SPACK_PATH/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0/*/.spack/*.txt -newer $SPACK_REPO_PATH/repo.yaml -exec cp --parents -r "{}" ./ \;
+    - mv .$SPACK_PATH/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0 spack_logs/installed
+    # not succesfully installed packages: also keep the spack logs for any packages that failed
     - cp --parents /tmp/$(whoami)/spack-stage/*/*.txt ./
-    - mv ./tmp/$(whoami)/spack-stage spack-logs
+    - mv ./tmp/$(whoami)/spack-stage spack_logs/not_installed
   artifacts:
     paths:
-      - spack-logs
+      - spack_logs
     when: always
   only:
     refs: