From 20bccd8ac61d56d576b795f340011fd47e0406c4 Mon Sep 17 00:00:00 2001 From: Eero Kelly Date: Tue, 9 Jun 2026 22:47:45 +0000 Subject: [PATCH] Copy only the latest few logfiles --- .../guestos/init/setup-encryption/setup-var-encryption.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ic-os/components/guestos/init/setup-encryption/setup-var-encryption.sh b/ic-os/components/guestos/init/setup-encryption/setup-var-encryption.sh index 64d4f6b3db76..b40274766c5a 100755 --- a/ic-os/components/guestos/init/setup-encryption/setup-var-encryption.sh +++ b/ic-os/components/guestos/init/setup-encryption/setup-var-encryption.sh @@ -9,9 +9,9 @@ function transfer_log_state() { MACHINE_ID=$(cat /etc/machine-id || echo invalid) echo "Successfully mounted old /var partition, copying contents for machine id: ${MACHINE_ID}" - # First, copy actual journal files. - mkdir -p /mnt/var_new/log/journal - if cp -vr /mnt/var_old/log/journal/"${MACHINE_ID}" /mnt/var_new/log/journal/"${MACHINE_ID}"; then + # First, copy latest journal files. + mkdir -p /mnt/var_new/log/journal/"${MACHINE_ID}" + if cp -pv $(ls -t /mnt/var_old/log/journal/"${MACHINE_ID}"/*.journal | head -3) /mnt/var_new/log/journal/"${MACHINE_ID}"/; then chown -R root.systemd-journal /mnt/var_new/log/journal/ chcon -R system_u:object_r:systemd_journal_t:s0 /mnt/var_new/log/journal/"${MACHINE_ID}" ls -lZ /mnt/var_new/log/journal/"${MACHINE_ID}"