Difference between revisions of "User:Woozle/toot.cat/2018/01/14"
(saving work) |
(next thing to do) |
||
| Line 15: | Line 15: | ||
* Decided it would simplify things if I went ahead and created the "tootcat" system user first. | * Decided it would simplify things if I went ahead and created the "tootcat" system user first. | ||
===Notes=== | ===Notes=== | ||
| − | + | Upgrading Mastodon: | |
| − | |||
| − | |||
| − | Upgrading Mastodon: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
===Work Log=== | ===Work Log=== | ||
====step 1==== | ====step 1==== | ||
Created user and group "tootcat" with /bin/bash as shell, no login allowed. I checked user "polymerwitch" (user for ''current'' Mastodon instance), and it has "sudo" membership -- but I'm not adding that, because it shouldn't be needed. | Created user and group "tootcat" with /bin/bash as shell, no login allowed. I checked user "polymerwitch" (user for ''current'' Mastodon instance), and it has "sudo" membership -- but I'm not adding that, because it shouldn't be needed. | ||
====step 2==== | ====step 2==== | ||
| + | I'm calling the new db <code>tootcat-masto-r1</code> (toot.cat Mastodon db revision 1). | ||
: <code>root@tootcat:~# '''createdb --owner=tootcat tootcat-masto-r1'''</code> | : <code>root@tootcat:~# '''createdb --owner=tootcat tootcat-masto-r1'''</code> | ||
:: <code>createdb: could not connect to database template1: FATAL: role "root" does not exist</code> | :: <code>createdb: could not connect to database template1: FATAL: role "root" does not exist</code> | ||
| Line 40: | Line 32: | ||
: <code>root@tootcat:~# '''su - postgres -c 'createdb --owner=tootcat tootcat-masto-r1''''</code> | : <code>root@tootcat:~# '''su - postgres -c 'createdb --owner=tootcat tootcat-masto-r1''''</code> | ||
:: Success. | :: Success. | ||
| − | ====step 3==== | + | ====step 3: migrate the data==== |
| + | Done earlier -- inside <code>/root/backups</code>: | ||
| + | : <code>su - postgres -c 'pg_dump mastodon' > tootcat.sql</code> | ||
| + | |||
[https://www.postgresql.org/docs/current/static/backup-dump.html Importing the data dump] into the new db: | [https://www.postgresql.org/docs/current/static/backup-dump.html Importing the data dump] into the new db: | ||
: <code>root@tootcat:~# '''cd /root/scratch'''</code> | : <code>root@tootcat:~# '''cd /root/scratch'''</code> | ||
| Line 77: | Line 72: | ||
: <code>root@tootcat:/var/lib/postgresql# '''su - postgres -c 'psql tootcat-masto-r1 < tootcat.sql''''</code> | : <code>root@tootcat:/var/lib/postgresql# '''su - postgres -c 'psql tootcat-masto-r1 < tootcat.sql''''</code> | ||
:: ...and then stuff started happening that ''might'' have been the output of a successful import. | :: ...and then stuff started happening that ''might'' have been the output of a successful import. | ||
| + | |||
| + | After taking a brief break, I come back to find that the process has completed... and a brief inspection shows that the db seems to be populated with data. I'm calling this step complete, then. | ||
| + | ====step 4: installing Mastodon==== | ||
| + | The [https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Updating-Mastodon-Guide.md official upgrade instructions] mention that you should only ever use "tagged releases on production Mastodon instances", and therefore: | ||
| + | <syntaxhighlight lang=bash> | ||
| + | su - mastodon | ||
| + | cd ~/live | ||
| + | git pull | ||
| + | git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1) | ||
| + | </syntaxhighlight> | ||
| + | ...except corrected for how things are set up here. | ||
Revision as of 20:01, 14 January 2018
2018-01-14
My current plan is:
- create new system user "tootcat"
- create a new Postgres db for toot.cat's Mastodon
- migrate the data there
- install Mastodon under user "tootcat"
- run Mastodon's schema upgrade rake task
- test the result as https://new.toot.cat (get it working)
- write a script to automate the data migration
- in close succession:
- run the migration script
- reconfigure nginx to point to the new instance
revisions
- Decided it would simplify things if I went ahead and created the "tootcat" system user first.
Notes
Upgrading Mastodon:
Work Log
step 1
Created user and group "tootcat" with /bin/bash as shell, no login allowed. I checked user "polymerwitch" (user for current Mastodon instance), and it has "sudo" membership -- but I'm not adding that, because it shouldn't be needed.
step 2
I'm calling the new db tootcat-masto-r1 (toot.cat Mastodon db revision 1).
root@tootcat:~# createdb --owner=tootcat tootcat-masto-r1createdb: could not connect to database template1: FATAL: role "root" does not exist- Apparently pg assumes whatever the current system user is as its internal user as well.
root@tootcat:~# su - postgres -c 'createdb --owner=tootcat tootcat-masto-r1'createdb: database creation failed: ERROR: role "tootcat" does not exist
root@tootcat:~# createuser --createdb tootcatcreateuser: could not connect to database postgres: FATAL: role "root" does not exist- can't say I'm surprised
root@tootcat:~# su - postgres -c 'createuser --createdb tootcat'- Success.
root@tootcat:~# su - postgres -c 'createdb --owner=tootcat tootcat-masto-r1'- Success.
step 3: migrate the data
Done earlier -- inside /root/backups:
su - postgres -c 'pg_dump mastodon' > tootcat.sql
Importing the data dump into the new db:
root@tootcat:~# cd /root/scratchroot@tootcat:~/scratch# lstootcat.sql
root@tootcat:~/scratch# psql tootcat-masto-r1 < tootcat.sqlpsql: FATAL: role "root" does not exist- I actually expected this, but just wanted to make sure.
root@tootcat:~/scratch# su - postgres -c 'psql tootcat-masto-r1 < tootcat.sql-su: tootcat.sql: No such file or directory- Apparently this operates relative to the
postgresuser's home folder, or wherever you get put by default when logging in. Okay.
- Apparently this operates relative to the
root@tootcat:~/scratch# su - postgres -c 'psql tootcat-masto-r1 < /root/scratch/tootcat.sql'-su: /root/scratch/tootcat.sql: Permission denied- This is also unsurprising. Other users shouldn't have access to /root files.
It was more or less at this point that I discovered that the tootcat.sql file was zero bytes long, so apparently the export process wasn't happy either.
There's no /home/postgres, so we can't go there.
/root/scratch is already mode 777, so apparently that's insufficient.
Oh, but the actual tootcat.sql file is in /root/backups. Just to be sure, then:
root@tootcat:~/scratch# cd ../backups/root@tootcat:~/backups# su - postgres -c 'psql tootcat-masto-r1 < /root/backups/tootcat.sql'-su: /root/backups/tootcat.sql: Permission denied- As expected.
And then it finally occurred to me:
root@tootcat:~/backups# su - postgres -c 'pwd'/var/lib/postgresql- Oh! Sneaksy, having a home folder outside of the
/homefolder. Just because/rootdoes it doesn't make it okay; do as I say, not as I do....
- Oh! Sneaksy, having a home folder outside of the
root@tootcat:~/backups# cd /var/lib/postgresql/root@tootcat:/var/lib/postgresql# mv /root/backups/tootcat.sql ./root@tootcat:/var/lib/postgresql# chown postgres:postgres tootcat.sqlroot@tootcat:/var/lib/postgresql# su - postgres -c 'psql tootcat-masto-r1 < tootcat.sql'- ...and then stuff started happening that might have been the output of a successful import.
After taking a brief break, I come back to find that the process has completed... and a brief inspection shows that the db seems to be populated with data. I'm calling this step complete, then.
step 4: installing Mastodon
The official upgrade instructions mention that you should only ever use "tagged releases on production Mastodon instances", and therefore:
su - mastodon
cd ~/live
git pull
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
...except corrected for how things are set up here.