How to backup and restore a whole /var/discourse
folder?
Due to issues with the usual backup and restoration process, I was wondering if I could backup the whole /var/discourse
folder and re-use it on another server. This is what I did…
On production server:
rsync_opts="\
--recursive \
--links \
--hard-links \
--safe-links \
--owner \
--group \
--perms \
--times \
--delete \
--sparse \
--compress \
--partial \
--rsh=ssh
"
dir=/var/discourse
rsync $rsync_opts "$dir/" root@xx.xx.xx.xx:"/var/production-backup/$dir"
On stage server:
Install docker.
rsync --recursive --links --hard-links --safe-links --owner --group --perms --times --delete --sparse --compress --partial /var/production-backup/var/discourse/ /var/discourse
But getting 502 Bad Gateway
.
Trying to investigate.
cd /var/discourse
./launcher start app
root@whonix-app:/var/www/discourse# service postgresql status
12/main (port 5432): down
root@whonix-app:/var/www/discourse# service postgresql start
[....] Starting PostgreSQL 12 database server: main[....] Error: The cluster is owned [FAILoup id 116 which does not exist ... failed!
failed!
Guess some fixes:
chown -R postgres.postgres /etc/postgresql
chown -R postgres.postgres /shared/postgres_*
chown -R postgres.postgres /var/lib/postgresql
chown -R postgres.postgres /var/log/postgresql
chown -R redis.redis /etc/redis/redis.conf
chown -R redis.redis /shared/redis_data
chown -R redis.redis /var/run/redis
chown -R redis.redis /var/lib/redis
chown -R redis.redis /var/log/redis
chgrp -R ssl-cert /etc/ssl/private
But did not help.
root@whonix-app:/var/www/discourse# service postgresql start
[....] Starting PostgreSQL 12 database server: main[....] Error: /usr/lib/postgresql/12/bin/pg_ctl /usr/lib/postgresql/12/bin/pg_ctl start -D /shared/postgres_data -l /var/log/postgresql/postgresql-12-main.log -s -o -c config_file="/etc/postgresql/12/main/postgresql.conf" exited with status 1: 2020-05-25 10:20:10.501 UTC [603] FATAL: database files are incompatible with server 2020-05-25 10:20:10.501 UTC [603] DETAIL: The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 12.2 (Debian 12.2-2.pgdg100+1). pg_ctl: could not start server Examine the lo[FAILput. ... failed!
failed!
Why are these file permission issues introduced?
Why is postgres updated from version 10 to version 12 by simply copying the whole folder from one server to another? I must be doing something wrong.
Could you please kindly share instructions on how to backup the whole discourse app on one server and move it to another server?