§
step 0:
- always check the release pages for breaking changes.
- make sure you have proper backups
- use e.g. tmux so that your session is not interrupted by internet conditions
Important docs
§
backups
[+] click to expand a sample pleroma backup script
assuming pleroma is installed from source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
!!! do not run scripts from internet without knowing what it does !!!
# CHANGE THIS TO YOUR OWN CONFIG
PLEROMA_DB=pleroma # name of the database
BACKUP_DIR=/backups # path to backup storage
PLEROMA_INSTALL=/opt/pleroma # path to pleroma installation
PLEROMA_UPLOADS=/srv/pleroma # optionally you can backup pleroma statics (FEs, emojis, uploads etc.)
POSTGRES_USER=postgres # system user for postgresql,
# by default it would be "postgres"
# you may want a timestamp for automated backups
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
# use a temporary dir to collect all the data to create the final archive.
DUMP_DIR=/tmp/pleroma_dump/$TIMESTAMP
mkdir -p $DUMP_DIR
# dump the database(s)
sudo pg_dump --username=$POSTGRES_USER -d $PLEROMA_DB --format=custom -f $DUMP_DIR/postgres.dump
# you may want to check the return code for the previous command.
# backup important pleroma configs (optionally you could backup the whole
# pleroma production installation (e.g. /opt/pleroma)
cp $PLEROMA_INSTALL/config/prod.secret.exs $DUMP_DIR/prod.secret.exs
cp $PLEROMA_INSTALL/config/setup_db.psql $DUMP_DIR/setup_db.psql
# create an archive
tar -czvf $BACKUP_DIR/$TIMESTAMP.tar.gz -C $DUMP_DIR . -C $PLEROMA_UPLOADS . >> /dev/null
# check results and remove the temporary dir
if [ $? -eq 0 ]; then
echo [$TIMESTAMP] archive created
rm -rf $DUMP_DIR
fi
|
§
upgrade postgresql (+migration)
You need to manually migrate the postgresql database when updating the
postgres by major version, e.g. from 14.x to 15.y; You don’t have to do this
when updating from e.g. 14.x to 14.y
Supposing upgrading from 14.x to 15.y, you need to make sure the 14.x postgresql
binary is still available when doing the migration.
archlinux provides the
postgresql-old-upgrade
package which provides the postgresql binary 1 version behind the main repo
postgresql.
My notes on upgrading pg
Here are some quick notes, but make sure you know what you are doing.
- make sure you have a proper backup
- stop postgresql service:
systemctl stop postgresql
- update the postgresql binary and make sure you keep the old binary (see above)
- run the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# prepare dirs for live data migration
mv /var/lib/postgres/data /var/lib/postgres/olddata
mkdir /var/lib/postgres/data /var/lib/postgres/tmp
chown postgres:postgres /var/lib/postgres/data /var/lib/postgres/tmp
# switch to postgres user
sudo -iu postgres
# go to tmp dir and perform migration
cd /var/lib/postgres/tmp
# initialize the "new" DB. You'll need the parameters that you used to
# intialize the postgresql db for the first time. (if you follow pleroma
# installation guide this should be empty.)
initdb -D /var/lib/postgres/data --PARAMETERS_USED_TO_INIT_DB
# perform migration:
pg_upgrade -b /opt/pgsql-PG_VERSION/bin -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data
# restart postgresql
|
for archlinux
optionally, to avoid suprises, do not update postgresql packages.
warning: postgresql: ignoring package upgrade (16.3-4 => 17.4-1) │
warning: postgresql-libs: ignoring package upgrade (16.3-4 => 17.4-1) │
warning: postgresql-old-upgrade: ignoring package upgrade (15.7-3 => 16.6-2)
§
install (update) pleroma from source
https://docs-develop.pleroma.social/backend/administration/updating/