Page MenuHomeVyOS Platform

Save bash history during image upgrade
Closed, ResolvedPublic

Description

When upgrading (adding) the system image, the installer prompts the user to copy configuration and SSH host keys to the new image - but bash history is not preserved. It is silently lost, forcing operators to start with an empty history after every upgrade.

vyos@vyos1:~$ add system image 2026.06.22-1616-integration.iso
...
An active configuration was found. Would you like to copy it to the new image? [Y/n]
Copying configuration directory
Would you like to copy SSH host keys? [Y/n]
Copying SSH host keys
Copying system image files
...

Solution: extend the image upgrade script to detect and migrate the history file from the currently running image to the newly installed one.

vyos@vyos1:~$ add system image 2026.06.22-1616-integration.iso
...
Would you like to copy bash history? [y/N]
...
Copying bash history
...

Details

Version
-
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

o.kuchmystyi triaged this task as Normal priority.
o.kuchmystyi changed the task status from Open to In progress.Jul 15 2026, 9:58 AM

Will chmod and chown be preserved on the directories and files being copied?

I checked it manually and it looks like the metadata was transferred after upgrade:

vyos@vyos1:~$ sudo stat -c '%a %U:%G' .bash_history
600 vyos:users
vyos@vyos1:~$ sudo stat -c '%a %U:%G' .ssh/known_hosts
644 vyos:users
vyos@vyos1:~$ add system image vyos-999.202607231048-generic-amd64.iso
Validating image compatibility
Validating image checksums
...
Would you like to copy SSH host keys? [Y/n]
Copying SSH host keys
Would you like to save the SSH known hosts (fingerprints) from your current configuration? [Y/n]
Copying SSH known_hosts files
Would you like to copy bash history? [y/N] y
Copying bash history
...
vyos@vyos1:~$ sudo reboot now
...
vyos@vyos1:~$ sudo stat -c '%a %U:%G' .bash_history
600 vyos:users
vyos@vyos1:~$ sudo stat -c '%a %U:%G' .ssh/known_hosts
644 vyos:users

Is this also true for multiple users so they not all end up with vyos:users?

Yes, I can confirm that it works the same with multiple users in the system:

vyos@vyos1:~$ sudo stat -c '%a %U:%G' .bash_history
600 vyos:users
vyos@vyos1:~$ su - testuser
testuser@vyos1:~$ pwd
/home/testuser
testuser@vyos1:~$ sudo stat -c '%a %U:%G' .bash_history
600 testuser:users