Software Update Procedure

Option 1: Docker

Update


docker-compose down
docker-compose pull
docker-compose up -d

Basics

The easiest way to do a software update is to grab the latest project TAR file from the project development repository and then perform the software update on the production server as follows:

Details

<Directory /var/www/drdb.bak>
deny from all
</Directory>
#!/bin/bash

# Directories, adapt as required
WWW_PATH="/var/www"
HOME_PATH="/home/martin"
DRDB_DIR_NAME="drdb"

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit 1
fi

if [[ $# -eq 0 ]] ; then
    echo 'filename of tar file missing'
    exit 1
fi

echo 'extracting TAR archive...'

cd $WWW_PATH
sudo rm -rf $DRDB_DIR_NAME".bak"
sudo mv $DRDB_DIR_NAME $DRDB_DIR_NAME".bak"
sudo mkdir $DRDB_DIR_NAME
cd $DRDB_DIR_NAME

if sudo tar -xf $HOME_PATH/$1
then
    echo 'success!'
else
    echo 'tar extract error, rolling back'
    cd $WWW_PATH
    sudo rm -rf $DRDB_DIR_NAME
    sudo mv $DRDB_DIR_NAME".bak" $DRDB_DIR_NAME
    cd $HOME_PATH
    exit 1
fi

cd $WWW_PATH

echo 'copying log and config files and adapting access permissions...'

# Get drdb log file from the backup and put it into new directory
sudo cp "./"$DRDB_DIR_NAME".bak/log/drdb-logfile.txt" "./"$DRDB_DIR_NAME"/log/"

# Images also need to be copied from the backup to the new directory
sudo cp "./"$DRDB_DIR_NAME".bak/images/db-front-pic.jpg" "./"$DRDB_DIR_NAME"/images/"
sudo cp "./"$DRDB_DIR_NAME".bak/images/db-front-pic-xs.jpg" "./"$DRDB_DIR_NAME"/images/"

# Get the configuration files from the backup and put them into the new directory
sudo cp -R "./"$DRDB_DIR_NAME".bak/config" "./"$DRDB_DIR_NAME


sudo chmod -R 755 $DRDB_DIR_NAME
sudo chown -R www-data:www-data $DRDB_DIR_NAME

echo 'done!'