We have an installation of LimeSurvey to create surveys:

https://survey.tails.boum.org/

Infrastructure

Puppet configuration files:

Git repositories:

  • Upstream repo in https://github.com/LimeSurvey/LimeSurvey.git.

  • Updates repo in /var/lib/limesurvey/ which is synced automatically to the upstream repo.

  • Production repo in /var/www/limesurvey which has the update repo as origin.

Updating LimeSurvey

  1. Log in to the administration interface to identify which version is currently installed:

    https://survey.tails.boum.org/index.php/admin

  2. Read the release notes:

    https://github.com/LimeSurvey/LimeSurvey/blob/master/docs/release_notes.txt.

  3. Connect to the platform:

    ssh unlehxtgqn5xg6ccxwnm5w3ddcrll5ctlavo7srjvkkpay67dv3sdzyd.onion
    
  4. Update the backup of the database:

    sudo /usr/sbin/backupninja --now --debug --run /etc/backup.d/10.mysql
    
  5. Login as www-data:

    sudo -u www-data bash
    cd ~/limesurvey/
    
  6. Save a backup of the custom files in the working directory:

    tar zcvf /tmp/limesurvey-$(date +%Y-%m-%d-%H:%M).tgz application/config/config.php upload
    
  7. Fetch the changes from the updates repo:

    git fetch origin
    
  8. Check the version number in the production repo and the updates repo:

    git log master
    git log origin/master
    
  9. Identity the tag to which to update:

    git tag
    
  10. Merge the updates repo (or the upstream repo) into the production repo:

    git merge $TAG
    

    Remove all untracked files:

    git clean -df
    

    Restore the custom files:

    tar zxvf /tmp/limesurvey-$(date +%Y-%m-%d)-*.tgz
    
  11. Make sure that our local changes are still here:

    git log --no-merges $TAG..
    

    Should return:

    commit 38a457d28c4a0598e17692d8c99dd8f6ccdc0200 (HEAD)
    Author: www-data <www-data@survey.lizard>
    Date:   Thu Aug 3 18:53:17 2023 +0000
    
        Use a more generic message (fundraising#17704)
    
        We're now using LimeSurvey to send emails to donors.
    
  12. Update the database from either:

    One might work but not the other.

  13. Check the version in the footer of:

    https://survey.tails.boum.org/index.php/admin/index

  14. Remove the backup of the custom files:

    rm /tmp/limesurvey-*.tgz
    

Deleting old tables

When a survey is deactivated in LimeSurvey, the data of the survey (responses and list of participants) is moved to MySQL tables with the prefix old_.

To delete all these tables at once:

  1. Connect to the platform:

    ssh unlehxtgqn5xg6ccxwnm5w3ddcrll5ctlavo7srjvkkpay67dv3sdzyd.onion
    
  2. Update the backup of the database:

    sudo /usr/sbin/backupninja --now --debug --run /etc/backup.d/10.mysql
    
  3. Login as www-data:

    sudo -u www-data bash
    
  4. Store the MySQL password in a shell variable:

    grep "'password' =>" /var/www/limesurvey/application/config/config.php | sed -r "s/^\s+'password' => '(\w+)',$/\1/"
    export PASSWORD=
    
  5. Delete all tables that have the prefix old_:

    echo "show tables like 'old_%';" | mysql --user limesurvey --password=${PASSWORD} --skip-column-names limesurvey | while read table ; do echo "Dropping $table..." ; echo "drop table $table;" | mysql --user limesurvey --password=${PASSWORD} limesurvey ; done
    
  6. Update the backup of the database to overwrite the previous one:

    sudo /usr/sbin/backupninja --now --debug --run /etc/backup.d/10.mysql