RaspberryPi4B: Difference between revisions

From Wiki RB4
 
(9 intermediate revisions by the same user not shown)
Line 48: Line 48:
** can be tested by <code>ssh raspberry3</code>
** can be tested by <code>ssh raspberry3</code>
** install sshfs
** install sshfs
** create mount <code>/home/uwe/backup/mnt_raspberry3_for_backup</code>
** check sshfs access by <code>sshfs raspberry3:/media/usbstick/backup /home/uwe/backup/mnt_raspberry3_for_backup</code>
*** <code>ls</code> should show <code>owncloud</code> directory and zip file inside
** create <code>/home/uwe/.config/systemd/user/mount_raspberry3.service</code>
** create <code>/home/uwe/bin/mount_raspberry3.sh</code>
** setup service by
*** <code>systemctl --user daemon-reload</code>
*** <code>systemctl --user restart mount_raspberry3.service</code>
*** <code>systemctl --user status mount_raspberry3.service // check status </code>
*** <code>systemctl --user enable mount_raspberry3.service</code>
*** and make it permanent after reboot by <code>loginctl enable-linger uwe</code>
** install rclone and configure Google backup drive <code>uh_gdrive_backup</code> (see [https://drive.google.com/drive/folders/1m5lQlZf6a5zJwJ_MsUNu1OpwGw65IxN2 Google Drive])
** install rclone and configure Google backup drive <code>uh_gdrive_backup</code> (see [https://drive.google.com/drive/folders/1m5lQlZf6a5zJwJ_MsUNu1OpwGw65IxN2 Google Drive])
** create <code>~/backup/raspberry3/backup_raspberry3.sh</code>
** <code>crontab -e</code> and add <code>0 4 * * * nice -n 19 /home/uwe/backup/raspberry3/backup_raspberry3.sh</code>
** check by <code>crontab -l</code>
* VNC is already part of installation
* VNC is already part of installation


Line 127: Line 113:
=====Content=====
=====Content=====
* Version, Extensions, ... https://uweheuer.spdns.de/mediawiki_new/index.php?title=Special:Version
* Version, Extensions, ... https://uweheuer.spdns.de/mediawiki_new/index.php?title=Special:Version
=====Backup=====
* see [[RaspberryPi4B#Backup_of_Mediawiki|here]]


====Test Environment====
====Test Environment====
Line 146: Line 134:
* adjust <code>docker-compose.yml</code> so that <code>LocalSettings.php</code>
* adjust <code>docker-compose.yml</code> so that <code>LocalSettings.php</code>
* copied some variables from production to make it accessible
* copied some variables from production to make it accessible
======Enable Image Uploads e.g. for Visual Editor======
in <code>LocalSettings.php</code>
$wgEnableUploads = true;
$wgUploadDirectory = "$IP/images";
$wgUploadPath = "$wgScriptPath/images";
in container by <code>docker exec -it  mediawiki-docker-test-1_mediawiki_1 bash</code>:
cd /var/www/html
mkdir -p images/temp
chown -R www-data:www-data images
chmod -R 755 images
on Raspberry:
sudo chmod -R 777 ./images


=====Content=====
=====Content=====
Line 250: Line 252:
** writes log file <code>/home/uwe/backup/Raspberry3B/backup_raspberry3.log</code>
** writes log file <code>/home/uwe/backup/Raspberry3B/backup_raspberry3.log</code>
* schedule job which runs every night at 4 by <code>crontab -e</code> with <code>nice</code> to maintain responsiveness of the system
* schedule job which runs every night at 4 by <code>crontab -e</code> with <code>nice</code> to maintain responsiveness of the system
* check by <code>sudo crontab -l</code>
===Backup of Raspberry 4===
====Backup of Mediawiki====
* <code>/home/uwe/backup/raspberry4/backup_raspberry4.sh</code>
** write log file <code>/home/uwe/backup/raspberry4/backup_raspberry4.log</code>
** zips mysql DB and LocalSettings.php from production to <code>/home/uwe/backup/raspberry4/mediawiki/mediawiki_backup.zip</code>
** copies zip file by rclone to Google drive backup sub-folder <code>/raspberry4/mediawiki/</code>


==Operation==
==Operation==

Latest revision as of 21:46, 3 November 2025

Type Information[edit]

  • Raspberry 4B 8GB (1,5 GHz Quad-Core ARM-Cortex A72 CPU)
  • bought at pi3g.com via their shop buyzero.de at 12/08/2021 as Raspberry Pi 4 Server Set:
    • 64GB microSD
    • USB C 5 Volt 3 Ampere Netzteil
    • microHDMI auf HDMI Kabel
    • FLIRC Gehäuse
    • CAT 6 LAN Kabel 2 m

Installation[edit]

Operating System[edit]

  • at 2025-09-15 change to version 12 bookworm
  • install rpi imager tool by
    • sudo apt update
    • sudo apt install rpi-imager
  • start VNCViewer on Laptop
  • open cmd shell and rpi-imager
  • select 64bit OS (bookwarm) and write to SD writer
  • poweroff and change SD, plug-in monitor, mouse and keyboard
  • switch on until asked to set
    • Country (Germany, German, Berlin)
    • User (uwe, <Lr><STANDARD><Lr>)
    • reboot
  • opens desktop
  • open terminal for checking fixed IP
    • ip link show eth0 gives MAC address e4:5f:01:47:89:ef
    • this is configured in fritz box
  • open terminal to enable ssh login, VNC
    • sudo raspi-config
    • Interface Options -> SSH
    • Interface Options -> VNC
  • check by
    • lsb_release -a
    • cat /etc/os-release
  • insert old boot sd card
    • it has two partitions boot and rootfs
  • prepare backup of Raspberry 3B like on the old OS
    • ssh-keygen and ssh-key-cp
    • because the new OS is using a new ssh version and a check with ssh -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa root@192.168.178.35 worked (login w/o password)
    • create ~/.ssh/config with
Host raspberry3
  HostName 192.168.178.35
  User root
  PubkeyAcceptedAlgorithms +ssh-rsa
  HostKeyAlgorithms +ssh-rsa
  IdentityFile /home/uwe/.ssh/id_rsa
    • can be tested by ssh raspberry3
    • install sshfs
    • install rclone and configure Google backup drive uh_gdrive_backup (see Google Drive)
  • VNC is already part of installation

Angular[edit]

npm install -g @angular/cli

Docker[edit]

  • installation according to here with the convenience script (because of the comment regarding raspberry installation)
curl -fsSL https://get.docker.com -o get-docker.sh
DRY_RUN=1 sudo sh ./get-docker.sh
sudo reboot
sudo usermod -aG docker $USER // logout and login
  • architecture is linux/arm64/v8
  • edited /usr/lib/systemd/system/docker.service, saved the old version to ~/SoftwareProjects/eclipse-workspace/uweheuer-backend/docker.service.2023-01-07 to get rid of iptables error and missing dPort parameter when calling docker compose up for uweheuerbackend

Test by:

docker 
docker version
docker compose version
docker run hello-world

Portainer Community Edition (CE)[edit]

mkdir ~/PortainerData
docker volume create portainer_data
docker run -d   -p 8000:8000 -p 9443:9443   --name portainer   --restart=always   -v /var/run/docker.sock:/var/run/docker.sock   -v portainer_data:/home/uwe/PortainerData   cr.portainer.io/portainer/portainer-ce:latest
admin <Lp><Lp><STANDARD><Lp><Lp>

Git and GitHub CLI[edit]

sudo apt install git
git --version
git config --global user.email uwe.heuer@gmail.com
git config --global user.name UweHeuer
  • GitHub CLI from here
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
  • test by
gh version

Java[edit]

java -version
sudo apt install openjdk-17-jdk

Maven[edit]

sudo apt install maven

Mediawiki[edit]

There are 2 docker compositions:

Production[edit]

Import from Raspberry 3[edit]
Content[edit]
Backup[edit]

Test Environment[edit]

Used for testing e.g. configuration changes or extensions

Installation[edit]
  • /home/uwe/mediawiki-docker-test-1/
  • routed via Raspberry 3 apache
  • create docker-compose.yml by copy from production
    • adjust port to 8081
  • Configuration during installation script(see also docker-compose.yml)
    • database host 'db'
    • database name 'wikidb'
    • database user 'wikiuser'
    • database password 'wikisecret'
    • Admin account 'uwe.heuer@gmail.com'
    • Admin pwd '<Lm><STANDARD><Lm>'
  • download LocalSettings.php and copy it into root of the docker
  • adjust docker-compose.yml so that LocalSettings.php
  • copied some variables from production to make it accessible
Enable Image Uploads e.g. for Visual Editor[edit]

in LocalSettings.php

$wgEnableUploads = true;
$wgUploadDirectory = "$IP/images";
$wgUploadPath = "$wgScriptPath/images";

in container by docker exec -it mediawiki-docker-test-1_mediawiki_1 bash:

cd /var/www/html
mkdir -p images/temp
chown -R www-data:www-data images
chmod -R 755 images

on Raspberry:

sudo chmod -R 777 ./images
Content[edit]
Operation[edit]

MySQL[edit]

Node.js[edit]

  • installation according to here
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install nodejs
node -v // prints v18.14.0
sudo apt install build-essential

PostgreS(QL)[edit]

// create a docker container
docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=Halloo0@1 -e POSTGRES_DB=postgres -e POSTGRES_USER=postgres -v pgdata:/var/lib/postgresql/data -d postgres
// -p <HOSTPORT>:<CONTAINERPORT>
// -e <ENV_VARIABLE>=<VALUE>
// -v <VOLUME_NAME>:<CONTAINER_DIR>
// -n <NAME>
pi@raspberrypi:~ $ docker volume inspect pgdata
[
    {
        "CreatedAt": "2021-09-30T21:44:54+01:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/pgdata/_data",
        "Name": "pgdata",
        "Options": null,
        "Scope": "local"
    }
]
// test access
C:\Uwes\Programme\PostgreSQL\12\bin> .\psql.exe -h uweheuer.spdns.de -U postgres postgres

// clean up everything
docker stop postgres
docker rm postgres
docker volume rm pgdata // this seems to be important, because it seems otherwise the password is denied

RClone[edit]

  • main purpose to backup to Google cloud
  • sudo apt install rclone
  • rclone config should be run from a cmd shell on a desktop because the browser is needed
  • test with
    • rclone listremotes
    • rclone ls uh_gdrive_backup:
    • rclone about uh_gdrive_backup:

Remode Desktop (RDP)[edit]

  • login via SSH
    • sudo apt install xrdp
    • sudo service xrdp start
  • remote desktop via Windows is empty => try VNC

SSH[edit]

  • login via cmd line
ssh uwe@uweheuer.spdns.de -p 54445 <Lr><STANDARD><Lr>

VNC (Remote Desktop)[edit]

  • update raspberry
  • install VNC server in a long process with ChatGPT error search and handling
  • reboot
  • install RealVNC Viewer on Windows

Backup[edit]

Backup of Raspberry 3B (Old OS)[edit]

  • fetch files from Raspberry 3B and copy it to Google Drive

Preparation[edit]

  • create keys in order to avoid providing user and password for accessing Raspberry3B by ssh-keygen // always enter
  • creates keyfile in ls -al /home/uwe/.ssh/
  • copy key to Raspberry3B ssh-copy-id root@192.168.178.35
  • test without entering password ssh root@192.168.178.35
  • create a mount to Raspberry3B mkdir -p ~/backup/mnt_raspberry3_for_backup
  • install sshfs sudo apt install sshfs
  • mount with sshfs sshfs root@192.168.178.35:/media/usbstick/backup /home/uwe/backup/mnt_raspberry3_for_backup
  • make it boot save by adding a row by sudo nano /etc/fstab
  • decomment allow_other in sudo nano /etc/fuse.conf
  • create /home/uwe/backup/Raspberry3B/backup_raspberry3.sh
    • copies files from raspberry 3 to raspberry 4 by cp -u -p /home/uwe/backup/mnt_raspberry3_for_backup/owncloud/owncloud_backup.zip /home/uwe/backup/Raspberry3B/owncloud/
      • -u := only if new
      • -p := preserve file attributes in particular timestamps
    • copies files to Google Drive by rclone copy /home/uwe/backup/Raspberry3B/owncloud/owncloud_backup.zip uh_gdrive_backup:/Raspberry3B/owncloud/
      • rclone copy will only copy files that are new or have changed.
      • the comparison is done using file size and modification time (mtime).
    • writes log file /home/uwe/backup/Raspberry3B/backup_raspberry3.log
  • schedule job which runs every night at 4 by crontab -e with nice to maintain responsiveness of the system
  • check by sudo crontab -l

Backup of Raspberry 4[edit]

Backup of Mediawiki[edit]

  • /home/uwe/backup/raspberry4/backup_raspberry4.sh
    • write log file /home/uwe/backup/raspberry4/backup_raspberry4.log
    • zips mysql DB and LocalSettings.php from production to /home/uwe/backup/raspberry4/mediawiki/mediawiki_backup.zip
    • copies zip file by rclone to Google drive backup sub-folder /raspberry4/mediawiki/

Operation[edit]

On/Off[edit]

  • on/off by plug-in/off power supply

Reboot[edit]

sudo reboot

Update[edit]

sudo apt-get update && sudo apt-get upgrade


Archive[edit]

Obsolete Update to 64-bit OS[edit]

  • installation of Windows app Pi Imager
  • write 64-bit OS lite (w/o desktop) to 64GB microSD
  • boot by plug in power
  • user 'uwe' <Lr><STANDARD><Lr>
  • fixed ip address by Fritzbox
  • execute 'raspi-config' and enable SSH, set timezone to Berlin, hostname to 'raspberrypi4', ...
  • check version by cat /etc/os-release
  • check 32-bit or 64-bit by uname -m arm64 is 64 bit

Obsolete Initial Operation[edit]

  • copy empty file named 'ssh' to root at microSD to enable SSH access
  • microSD to slot
  • plug-in USB power supply
  • login via SSH with user 'pi' and pwd 'raspberry'
  • enable WLAN via raspi-config
  • set fixed IP for LAN and WLAN via fritz.box to 192.168.178.(72|73)
  • update OS via
sudo apt update
sudo apt dist-upgrade