Migrate Data to Another Disk

High disk load may lead to delays in event arrivals. In severe cases, it might result in complete inoperability of FindFace Multi. One of the means for reducing the disk load is to migrate the FindFace Multi data storages to another disk.

In this section:

Prepare Disk

To prepare a disk for the data migration, do the following:

  1. Create a new mount point (/mnt/ffdata in our example).

    sudo mkdir /mnt/ffdata
    
  2. Create a partition.

    sudo parted /dev/sdb
    mklabel gpt
    mkpart primary ext4 1MiB 100%
    q
    sudo mkfs.ext4 /dev/sdb1
    
  3. Learn the UUID of the partition (sdb1 in our example).

    sudo blkid | grep sdb1
    /dev/sdb1: LABEL="data" UUID="0638ebe0-853e-43ea-8f35-bfae305695d1" TYPE="ext4" PARTUUID="8cebaacc-77d7-4757-b4c6-14147e92646c"
    
  4. Add the partition to fstab to make it automatically mount on booting.

    sudo vi /etc/fstab
    ------------
    #DATA mount
    UUID=0638ebe0-853e-43ea-8f35-bfae305695d1 /mnt/ffdata/    ext4    auto,user,rw     0       2
    -------------
    
  5. Mount all the filesystems.

    sudo mount -a
    

Migrate Photo and Video Storage

Note

We recommend that you get acquainted with FindFace Multi Data Storages before starting migration of storages.

To migrate the FindFace Multi photo and video storage, do the following:

  1. Inside the mount point, create directories (e.g., /mnt/ffdata/ffupload and /mnt/ffdata/findface-security) to store photos and recorded video chunks (if the Video Recorder was deployed). Then, move contents of the /opt/findface-multi/data/findface-upload/uploads/ and the /opt/findface-multi/data/findface-multi-legacy/uploads/ directories to the newly created directories.

    sudo mkdir /mnt/ffdata/ffupload
    sudo mkdir /mnt/ffdata/findface-security
    sudo cp -ax /opt/findface-multi/data/findface-upload/uploads/ -R /mnt/ffdata/ffupload/
    sudo cp -ax /opt/findface-multi/data/findface-multi-legacy/uploads/ -R /mnt/ffdata/findface-security/
    sudo rm -r /opt/findface-multi/data/findface-multi-legacy/uploads/
    sudo rm -r /opt/findface-multi/data/findface-upload/uploads/
    
  2. Mount the created directories (/mnt/ffdata/ffupload and /mnt/ffdata/findface-security in the example) into the corresponding containers. To do so, open the /opt/findface-multi/docker-compose.yaml configuration file and list them in the volumes of the sections mentioned in the example instead of the default directories.

    sudo vi /opt/findface-multi/docker-compose.yaml
    
    findface-upload:
      ...
      volumes: ['./configs/findface-upload/40-ffupload.sh:/docker-entrypoint.d/40-ffupload.sh:ro',
        '/mnt/ffdata/ffupload:/var/lib/ffupload']
    ...
    findface-multi-identity-provider:
      ...
      volumes: ['./configs/findface-multi-identity-provider/findface-multi-identity-provider.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-identity-provider-migrate:
      ...
      volumes: ['./configs/findface-multi-identity-provider/findface-multi-identity-provider.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-legacy:
      ...
      volumes: ['./configs/findface-multi-legacy/findface-multi-legacy.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-legacy-migrate:
      ...
      volumes: ['./configs/findface-multi-legacy/findface-multi-legacy.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-legacy-singleton-services:
      ...
      volumes: ['./configs/findface-multi-legacy/findface-multi-legacy.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    cleaner:
      ...
      volumes: ['./configs/findface-multi-legacy/findface-multi-legacy.py:/etc/findface-security/config.py:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-ui:
      ...
      volumes: ['./configs/findface-multi-ui/nginx-site.conf:/etc/nginx/conf.d/default.conf:ro',
          '/mnt/ffdata/findface-security/uploads:/var/lib/findface-security/uploads']
    ...
    findface-multi-file-mover:
      ...
      volumes: ['./configs/findface-multi-file-mover/findface-multi-file-mover.yaml:/etc/config.yml:ro',
          '/mnt/ffdata/findface-security/uploads:/mnt/slow_storage/uploads']
    
  3. Rebuild all FindFace Multi containers.

    cd /opt/findface-multi
    
    sudo docker-compose down
    
    sudo docker-compose up -d
    

Migrate Main Database (PostgreSQL)

To migrate the PostgreSQL database, do the following:

  1. Stop all FindFace Multi containers:

    cd /opt/findface-multi
    
    sudo docker-compose down
    
  2. Move the /opt/findface-multi/data/postgresql directory to the /mnt/ffdata directory.

    sudo mv /opt/findface-multi/data/postgresql /mnt/ffdata
    
  3. Specify the new path of the postgresql directory (/mnt/ffdata/postgresql in the example) to mount into the findface-multi-postgresql-1 container. To do so, open the /opt/findface-multi/docker-compose.yaml configuration file and list the /mnt/ffdata/postgresql directory in the volumes of the postgresql section instead of the default /opt/findface-multi/data/postgresql directory.

    sudo vi /opt/findface-multi/docker-compose.yaml
    
    postgresql:
    ...
      volumes: ['./configs/postgresql/40-init.sql:/docker-entrypoint-initdb.d/40-init.sql:ro',
        '/mnt/ffdata/postgresql:/bitnami/postgresql']
    
  4. Start all FindFace Multi containers.

    sudo docker-compose up -d