The script maintenance.sh
can be used to regularly update the PRi, services stack and finally to reboot the host if it is needed.
The script can be executed manually or to be scheduled for automated execution with cron:
# crontab -e
Add the following line:
0 4 * * 6 /home/ubuntu/home-media-server-pi/scripts/maintenance.sh 2>&1 | /home/ubuntu/home-media-server-pi/scripts/timestamp.sh >> /home/ubuntu/logs/maintenance.log
The script will be executed At 04:00 on Saturday. Logs from result are stored in file /home/ubuntu/logs/maintenance.log
.
Or other proposition is 0 4 15-22 * */2
- At 04:00 on Tuesday - in the middle of month between 15th and 22nd.
To cleanup old log file content configure the logrotate by creating the file /etc/logrotate.d/pi.maintenance
with content:
/home/ubuntu/logs/maintenance.log {
monthly
copytruncate
missingok
rotate 12
compress
delaycompress
notifempty
}
Major versions of PostgreSQL require data storage to be upgraded, or data to be exported/imported in new DB storage file. Here are the sequence of commands how to export/import all data from each one of the databases that are present.
docker-compose --env-file .env.pi up -d keycloakdb
docker-compose --env-file .env.pi exec keycloakdb pg_dumpall -U postgre > dumpk.sql
docker-compose --env-file .env.pi down
// Manually delete old data folder
// Manually increase version in docker-compose
docker-compose --env-file .env.pi up -d keycloakdb
cat dumpk.sql | docker exec -i keycloakdb psql -U postgre
docker-compose --env-file .env.pi down
docker-compose --env-file .env.pi up -d
docker-compose --env-file .env.pi up -d domodb
docker-compose --env-file .env.pi exec domodb pg_dumpall -p 5532 -U domodb > dumpd.sql
docker-compose --env-file .env.pi down
// Manually delete old data folder
// Manually increase version in docker-compose
docker-compose --env-file .env.pi up -d domodb
cat dumpd.sql | docker exec -i domodb psql -p 5532 -U domodb
docker-compose --env-file .env.pi down
docker-compose --env-file .env.pi up -d