I have an app registered as a service in Ubuntu 16.04
If I type:
journalctl -u myapp.service
I can see the logs for my app.
I am moving my app to a new VM where the same service will be in place. Is it possible to migrate the log files to the new VM so that if I type journalctl -u myapp.service
it will show all my old logs and any new logs seamlessly?
I have tried to swap in the contents of the old /var/log/journal directory into the new VM, and restarting the systemd-journald service, but it doesn't seem to work.
More Details:
- The logs are stored in /var/log/journal/< machine-id >/
- the directory contents look like this:
$ ls /var/log/journal/05b6b1e76c6040cc99b4d34977a98eca/ [email protected]~ [email protected]~ [email protected]~ [email protected]~ system@9b08b416ae4c47a78c24b4ed77c39ea2-0000000000000001-0005b3c2d1380bae.journal system@9b08b416ae4c47a78c24b4ed77c39ea2-0000000000000248-0005bccbf3f7d7c1.journal system@e5c655526bb54aa886764039cd37f897-0000000000000001-0005c4ce02f66caf.journal system.journal [email protected]~ [email protected]~ [email protected]~ [email protected]~ user-1000@7b4df282ccfe4816a30db088f2621493-00000000000000ab-0005b3c2d1be9c3b.journal user-1000.journal
- There are no files in /run/log/
- both old and new VMs share the same service, service-running user, and machine-id (this is because ultimately both VMs stem from (were copied from) the same VM just at different times and with minor software/configuration settings)
- the user I access the logs with 'ubuntu' has the same groups in both VMs:
$ groups
ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd
- journal version on both VMs is:
$ journalctl --version
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN
- I am not looking to hold the logs longer than what is configured in the journal settings
Whats Working
- replacing the contents of the journal folder entirely
- adjusting file ownership to root:systemd-journal as they were originally
- 'root' can now see the full log
- 'ubuntu' can only see some 'current' logs, which are confusing, as they are not what was copied over
journald
doing its job.) The question is real. I am left wondering ... whether this could be an XY problem.