Docker Consolidation Project, Part Eight

Docker Consolidation Project, Part Eight
Photo by Magda Vrabetz / Unsplash

Test PhotoPrism Migration

I'm finally able to come back to this Docker migration and I'm going to work on PhotoPrism's migration today.

Steps performed on PHOTOPRISM-01

  • sudo apt update
  • sudo apt upgrade
  • sudo docker-compose down
  • sudo docker-compose pull
  • sudo docker-compose up -d

Now that PhotoPrism is up to date I can try to use their backup program.

  • sudo docker compose exec photoprism photoprism backup -i -f - > /home/david/Backups/Photoprism/photoprism-db-'date +%F'.sql

This command throws out permission errors, even run by sudo. Let's take it back to just their basic script, without my customization.

  • docker compose exec photoprism photoprism backup -i -f
    • INFO[2024-01-30T16:01:01Z] writing backup to /photoprism/storage/backup/mysql/2024-01-30.sql
    • INFO[2024-01-30T16:01:02Z] completed in 1.062848897s
  • sudo /usr/bin/photoprism-backup
  • sudo cp /home/david/Backups/PhotoPrism/Archive/storage.tar /mnt/pictures
  • sudo cp /home/david/storage/backup/mysql/2024-01-30.sql /mnt/pictures

While that's working I'm going to start working on my test environment.

Steps performed on TEST-01

  • sudo mkdir /apps/PhotoPrism
  • nano /home/david/.win/PhotoPrism-Credential
username=_service_photoprism
password=
domain=domain.local
  • I save PhotoPrism-Credential
  • chmod 600 /home/david/.win/PhotoPrism-Credential
  • sudo nano /etc/fstab
# Test mount for PhotoPrism
//10.10.10.XXX/Data/Pictures/PhotoPrism /mnt/PhotoPrism cifs credentials=/home/david/.win/PhotoPrism-Credential,uid=1000,gid=1000,iocharset=utf8,vers=2.0 0 0
  • I save fstab
  • sudo mkdir /mnt/PhotoPrism
  • sudo reboot
  • mv /mnt/PhotoPrism/docker-compose.yml /home/david/temp
  • mv /mnt/PhotoPrism/2024-01-30.sql /home/david/temp
  • mv /mnt/PhotoPrism/storage.tar /home/david/temp
  • tar -xvzf /home/david/temp/storage.tar

Since that is going to take a while to unpack I take a pause for lunch before I come back to this.

  • sudo mv /home/david/temp/docker-compose.yml /apps/PhotoPrism/
  • sudo nano /apps/PhotoPrism/docker-compose.yml
      PHOTOPRISM_SITE_URL: "http://test1.domain.local/"  # public server URL incl http:// or https:// and /path, :port is optional
      - "/mnt/PhotoPrism:/photoprism/originals"       # Network mount to pictures
  • I save the file docker-compose.yml
  • cd /apps/PhotoPrism
  • sudo docker-compose pull
  • sudo docker-compose up -d

A quick test browse to http://test1.domain.local:2342 is successful.

  • sudo docker-compose down
  • sudo mv /home/david/temp/2024-01-30.sql /apps/PhotoPrism/storage/backup/
  • sudo mv serial/ /apps/PhotoPrism/storage/
  • sudo mv users/ /apps/PhotoPrism/storage/
  • sudo mv sidecar/ /apps/PhotoPrism/storage/
  • sudo mv config/ /apps/PhotoPrism/storage/
  • sudo mv cache/ /apps/PhotoPrism/storage/
  • sudo mv backup/ /apps/PhotoPrism/storage/
  • sudo mv albums/ /apps/PhotoPrism/storage/
  • sudo cp 2024-01-30.sql /apps/PhotoPrism/storage/backup
  • sudo chown -R root:root /apps/PhotoPrism/storage
  • sudo docker-compose up -d

And with that it looks like everything is functioning correctly after moving the files. Now to pull in the backup.

  • sudo docker-compose exec photoprism photoprism restore -i -f
    • ERRO[2024-01-30T18:18:40Z] no backup file found in /photoprism/storage/backup/mysql
  • sudo mkdir /apps/PhotoPrism/storage/backup/mysql
  • sudo mv /apps/PhotoPrism/storage/backup/2024-01-30.sql /apps/PhotoPrism/storage/backup/mysql
  • cd /apps/PhotoPrism
  • sudo docker-compose exec photoprism photoprism restore -i -f

Victory! It is working as I had hoped. So that's awesome! Now I can repeat the process and place the app on DOCKER-01.

Actual PhotoPrism Migration

Steps performed on DOCKER-01

  • mkdir /home/david/Backups/PhotoPrism
  • mkdir /home/david/Backups/PhotoPrism/Archive
  • sudo mkdir /mnt/PhotoPrism
  • sudo mkdir /apps/PhotoPrism
  • nano /home/david/.win/PhotoPrism-Credential
username=_service_photoprism
password=
domain=domain.local
  • I save the PhotoPrism-Credential file
  • chmod 600 /home/david/.win/PhotoPrism-Credential
  • sudo nano /etc/fstab
# Mount for PhotoPrism
//10.10.10.XXX/Data/Pictures/PhotoPrism /mnt/PhotoPrism cifs credentials=/home/david/.win/PhotoPrism-Credential,uid=1000,gid=1000,iocharset=utf8,vers=2.0 0 0
  • I saved fstab
  • sudo reboot

The mount is working correctly after the reboot so I can keep moving forward.

  • cp /mnt/PhotoPrism/2024-01-30.sql /home/david/temp
  • cp /mnt/PhotoPrism/docker-compose.yml /home/david/temp
  • cp /mnt/PhotoPrism/storage.tar /home/david/temp
  • tar -xvzf /home/david/temp/storage.tar
  • sudo mv /home/david/temp/docker-compose.yml /apps/PhotoPrism
  • cd /apps/PhotoPrism
  • sudo chmod 644 docker-compose.yml
  • sudo chown root:root docker-compose.yml
  • sudo nano docker-compose.yml
      PHOTOPRISM_SITE_URL: "http://docker1.domain.local/"  # public server URL incl http:// or https:// and /path, :port is optional
      - "/mnt/PhotoPrism:/photoprism/originals"       # Network mount to pictures
  • I save the docker-compose.yml file
  • sudo docker-compose pull
  • sudo docker-compose up -d
    • ERROR: for photoprism_photoprism_1 Cannot start service photoprism: error while creating mount source path 'mnt/PhotoPrism': mkdir /mnt/PhotoPrism: file exists
    • ERROR: for photoprism Cannot start service photoprism: error while creating mount source path '/mnt/PhotoPrism': mkdir /mnt/PhotoPrism: file exists
    • ERROR: Encountered errors while bringing up the project.

That's interesting. Where's my error?

  • sudo docker-compose down
  • sudo nano docker-compose.yml

I don't see anything wrong in my .yml file. No typos anywhere that would be causing trouble. What the heck did I mess up?

  • sudo docker-compose up -d
  • sudo docker-compose ps
         Name                        Command                  State                   Ports
-------------------------------------------------------------------------------------------------------
photoprism_mariadb_1      docker-entrypoint.sh mysql ...   Up             3306/tcp
photoprism_photoprism_1   /scripts/entrypoint.sh /op ...   Up             0.0.0.0:2342-
                                                                          >2342/tcp,:::2342->2342/tcp,
                                                                          2442/tcp, 2443/tcp
photoprism_watchtower_1   /watchtower                      Up (healthy)   8080/tcp

Ok....so that was a rather interesting error. Anyone have any ideas? I test browse to http://docker1.domain.local:2342 and PhotoPrism loads for me. Victory! Now to move my data in.

  • sudo docker-compose down
  • cd /apps/PhotoPrism/storage
  • sudo rm serial
  • sudo rm -R albums/
  • sudo rm -R backup/
  • sudo rm -R cache/
  • sudo rm -R config/
  • sudo rm -R sidecar/
  • sudo rm -R users/
  • cd /home/david/temp/home/david/storage
  • sudo cp serial /apps/PhotoPrism/storage
  • sudo cp -R albums/ /apps/PhotoPrism/storage/
  • sudo cp -R backup/ /apps/PhotoPrism/storage/
  • sudo cp -R cache/ /apps/PhotoPrism/storage/
  • sudo cp -R config/ /apps/PhotoPrism/storage/
  • sudo cp -R sidecar/ /apps/PhotoPrism/storage/
  • sudo cp -R users/ /apps/PhotoPrism/storage/
  • sudo mkdir /apps/PhotoPrism/storage/backup/mysql
  • sudo cp 2024-01-30.sql /apps/PhotoPrism/storage/backup/mysql
  • cd /apps/PhotoPrism
  • sudo docker-compose up -d

I go that same error message. Strange. What the heck is up with that?

  • sudo docker-compose up -d

It comes up without issues this time.

  • sudo docker-compose exec photoprism photoprism restore -i -f
    • INFO[2024-01-30T23:24:10Z] restoring index from /photoprism/storage/backup/mysql/2024-01-30.sql
    • INFO[2024-01-30T23:24:16Z] migrating index database schema
    • INFO[2024-01-30T23:24:17Z] restored in 6.587121533s

There we go, all transitioned to the new server. My next step will be to tear down the test environment.

Steps performed on TEST-01

  • cd /apps/PhotoPrism
  • sudo docker-compose down
  • sudo rm -R app/PhotoPrism
  • sudo nano /etc/fstab
  • I remove the entry for PhotoPrism and save fstab
  • cd /home/david/temp
  • sudo rm 2024-01-30.sql
  • sudo rm storage.tar
  • sudo reboot
  • sudo rm -R /mnt/PhotoPrism

That's it for the test environment!

Decommission PHOTOPRISM-01

Steps performed on PHOTOPRISM-01

  • sudo shutdown now

Steps performed on DC-02 via Windows Admin Center

  • I go to DNS
  • I click on domain.local
  • I select PHOTOPRISM.domain.local and click Edit
  • I change the IP address to DOCKER-01's IP address
  • I click Save
  • I select PHOTOS.domain.local and click Edit
  • I change the IP address to DOCKER-01's IP address
  • I click Save

Steps performed on HV-03 via Windows Admin Center

  • I navigate to Virtual Machines
  • I select PHOTOPRISM-01
  • I click Manage and then Delete
  • I select the option Delete virtual hard disk files

Steps performed on desktop

  • I deleted the PHOTOPRISM-01 SSH key files
  • I removed PHOTOPRISM-01 from the Windows Terminal JSON file

Steps performed on DOCKER-01

  • cd /apps/PhotoPrism
  • sudo nano docker-compose.yml
  • I change the following line:
    • PHOTOPRISM_SITE_URL: "https://photos.domain.com/" # public server URL incl http:// or https:// and /path, :port is optional
  • I save the docker-compose.yml file
  • sudo docker-compose stop
  • sudo docker-compose up -d

I go to test in a browser https://photos.domain.com, but it is not loading for me. I forgot about the firewall, is that it?

  • sudo ufw allow 2342

No that's not it, Docker by default opens the port in UFW so that wouldn't have been an issue. I verify my NGINX proxy is pointing to http://photos.domain.local:2342 and not an IP address so that should be just fine. I'm running out of time so I'll have to come back and figure out what's wrong tomorrow.