.. _rcc-upgrade-rollback-ref: Rollback to previous version ============================ Sometimes it might happen that there's a need to rollback an performed upgrade of your installed instances. In the below example we'll upgrade an instance from 4.5.2 version to 4.7.2 and then rollback to 4.5.2 again. .. important:: * Rollback instructions are based on |RCC| version 1.14 and later. If you're using an older version, make sure to upgrade it using `rccontrol self-update` * Please always make sure to have a backup of your Database * It's also recommended to additionally backup your `rhodecode.ini` and `vcsserver.ini` configuration files, in case there's some really custom configuration stored there. * Please read our release notes, and check `Upgrade notes` section for any additional information about important, or backward incompatible changes between releases. Here's our current installation, of 4.5.2 Community and VCSServer: .. code-block:: bash $ rccontrol status RHODECODE CONTROL VERSION: 1.14.0 - NAME: community-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/community-1/community.log - VERSION: 4.5.2 Community - VCS: vcsserver-1 - URL: http://127.0.0.1:10002 - CONFIG: /home/ubuntu/.rccontrol/community-1/rhodecode.ini - NAME: vcsserver-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/vcsserver-1/vcsserver.log - VERSION: 4.5.2 VCSServer - URL: http://127.0.0.1:10000 - CONFIG: /home/ubuntu/.rccontrol/vcsserver-1/vcsserver.ini We'll perform an upgrade of our instances by running: .. code-block:: bash $ rccontrol self-update && rccontrol upgrade "*" ... After the upgrade process finished, we check the status of our instances. .. code-block:: bash $ rccontrol status RHODECODE CONTROL VERSION: 1.14.0 - NAME: community-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/community-1/community.log - VERSION: 4.7.2 Community - VCS: vcsserver-1 - URL: http://127.0.0.1:10002 - CONFIG: /home/ubuntu/.rccontrol/community-1/rhodecode.ini - NAME: vcsserver-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/vcsserver-1/vcsserver.log - VERSION: 4.7.2 VCSServer - URL: http://127.0.0.1:10000 - CONFIG: /home/ubuntu/.rccontrol/vcsserver-1/vcsserver.ini After an upgrade is performed, |RCC| creates backups up certain elements to allow an easier rollback. .. code-block:: bash $ ls -l ~/.rccontrol/community-1/ ... lrwxrwxrwx 1 ubuntu ubuntu 93 May 5 10:45 backup -> /opt/rhodecode/store/cgg0ln7k2xdn96xi5kp8phzl5320aay9-python2.7-rhodecode-enterprise-ce-4.5.2 ... lrwxrwxrwx 1 ubuntu ubuntu 93 May 5 10:45 profile -> /opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2 ... -rw-rw-r-- 1 ubuntu ubuntu 22806 May 5 10:45 rhodecode.backup_4.5.2.ini -rw-rw-r-- 1 ubuntu ubuntu 22806 May 5 10:45 rhodecode.ini ... $ ls -l ~/.rccontrol/vcsserver-1/ ... lrwxrwxrwx 1 ubuntu ubuntu 89 May 5 10:45 backup -> /opt/rhodecode/store/wa9qdk4q88qvlrfjdgiv07qwxdr3s73a-python2.7-rhodecode-vcsserver-4.5.2 ... lrwxrwxrwx 1 ubuntu ubuntu 89 May 5 10:45 profile -> /opt/rhodecode/store/xpdg97yhawxyvrh90666414x459kriq3-python2.7-rhodecode-vcsserver-4.7.2 ... -rw-rw-r-- 1 ubuntu ubuntu 2401 May 5 10:45 vcsserver.backup_4.5.2.ini -rw-rw-r-- 1 ubuntu ubuntu 2391 May 5 10:25 vcsserver.ini As we can see, a backup symlink is created that points to our previous installation, as well as backup of `rhodecode.ini` and `vcsserver.ini` with their respected version numbers from before upgrade. Internally RhodeCode uses the `profile` symlink to point the currently running system to installed version. If we move the `profile` symlink then we can switch which version is used. Here's how we can rollback our installation back to 4.5.2 version. * Stop our current instances, including supervisord process manager. .. code-block:: bash $ rccontrol self-stop Sent terminate signal to supervisord process: psutil.Process(pid=PID_ID, name='.supervisord-wr') Supervisord state is: STOPPED * First we start with rollback of VCSServer .. code-block:: bash $ cd ~/.rccontrol/vcsserver-1/ $ mv -v profile profile.upgraded && mv -v backup profile ‘profile’ -> ‘profile.upgraded’ ‘backup’ -> ‘profile’ $ mv -v vcsserver.ini vcsserver.ini.upgraded && cp -v vcsserver.backup_4.5.2.ini vcsserver.ini ‘vcsserver.ini’ -> ‘vcsserver.ini.upgraded’ ‘vcsserver.backup_4.5.2.ini’ -> ‘vcsserver.ini’ * Now rollback our Community. .. code-block:: bash $ cd ~/.rccontrol/community-1/ $ mv -v profile profile.upgraded && mv -v backup profile ‘profile’ -> ‘profile.upgraded’ ‘backup’ -> ‘profile’ $ mv -v rhodecode.ini rhodecode.ini.upgraded && cp -v rhodecode.backup_4.5.2.ini rhodecode.ini ‘rhodecode.ini’ -> ‘rhodecode.ini.upgraded’ ‘rhodecode.backup_4.5.2.ini’ -> ‘rhodecode.ini’ RhodeCode Guarantees that bugfix releases, e.g 4.7.1 -> 4.7.2 won't have any backward incompatible database changes. In such cases the rollback process would be finished. In our example we did a two major release upgrade. I.e 4.5.2 -> 4.7.2 It means we have to also *restore our database from before the upgrade*. After this has been done, the last step should be to start our instances again. .. code-block:: bash $ rccontrol self-init Starting supervisord. Supervisord state is: RUNNING Status command of rccontrol will show us that our instances are back in the 4.5.2 version. .. code-block:: bash $ rccontrol status RHODECODE CONTROL VERSION: 1.14.0 - NAME: community-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/community-1/community.log - VERSION: 4.5.2 Community - VCS: vcsserver-1 - URL: http://127.0.0.1:10002 - CONFIG: /home/ubuntu/.rccontrol/community-1/rhodecode.ini - NAME: vcsserver-1 - STATUS: RUNNING logs:/home/ubuntu/.rccontrol/vcsserver-1/vcsserver.log - VERSION: 4.5.2 VCSServer - URL: http://127.0.0.1:10000 - CONFIG: /home/ubuntu/.rccontrol/vcsserver-1/vcsserver.ini