From d61b7d4b4943f4b7919e1c1e4f155168e927b36a Mon Sep 17 00:00:00 2001 From: ilja Date: Mon, 29 May 2023 08:27:25 +0200 Subject: [PATCH 1/2] Improve backup restore CREATE DATABASE was running in a transaction block with CREATE USER. This isn't allowed (any more?). This is now two separate commands. I also did some other touch-ups including * making it OTP-first, * add backup of static directory because this contains e.g. custom emoji, and * remove the suggestion for using the setup_db.psql file. The reason is because I fear it causes more confusion than what it's worth. * Firstly, OTP installations won't have this file because it's created in /tmp. * Secondly, the instance has been reinstalled and thus a new setup_db.psql with different password may have been created, causing only more confusion. --- docs/docs/administration/backup.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/docs/docs/administration/backup.md b/docs/docs/administration/backup.md index 5c5df88ce..f1c96e009 100644 --- a/docs/docs/administration/backup.md +++ b/docs/docs/administration/backup.md @@ -4,12 +4,12 @@ 1. Stop the Akkoma service. 2. Go to the working directory of Akkoma (default is `/opt/akkoma`) -3. Run[¹] `sudo -Hu postgres pg_dump -d akkoma --format=custom -f ` (make sure the postgres user has write access to the destination file) -4. Copy `akkoma.pgdump`, `config/prod.secret.exs`[²], `config/setup_db.psql` (if still available) and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too. +3. Run `sudo -Hu postgres pg_dump -d akkoma --format=custom -f `[¹] (make sure the postgres user has write access to the destination file) +4. Copy `akkoma.pgdump`, `config/config.exs`[²], `uploads` folder, and [static directory](../configuration/static_dir.md) to your backup destination. If you have other modifications, copy those changes too. 5. Restart the Akkoma service. -[¹]: We assume the database name is "akkoma". If not, you can find the correct name in your config files. -[²]: If you've installed using OTP, you need `config/config.exs` instead of `config/prod.secret.exs`. +[¹]: We assume the database name is "akkoma". If not, you can find the correct name in your configuration files. +[²]: If you have a from source installation, you need `config/prod.secret.exs` instead of `config/config.exs`. The `config/config.exs` file also exists, but in case of from source installations, it only contains the default values and it is tracked by Git, so you don't need to back it up. ## Restore/Move @@ -17,19 +17,16 @@ 2. Stop the Akkoma service. 3. Go to the working directory of Akkoma (default is `/opt/akkoma`) 4. Copy the above mentioned files back to their original position. -5. Drop the existing database and user if restoring in-place[¹]. `sudo -Hu postgres psql -c 'DROP DATABASE akkoma;';` `sudo -Hu postgres psql -c 'DROP USER akkoma;'` -6. Restore the database schema and akkoma role using either of the following options - * You can use the original `setup_db.psql` if you have it[²]: `sudo -Hu postgres psql -f config/setup_db.psql`. - * Or recreate the database and user yourself (replace the password with the one you find in the config file) `sudo -Hu postgres psql -c "CREATE USER akkoma WITH ENCRYPTED PASSWORD ''; CREATE DATABASE akkoma OWNER akkoma;"`. +5. Drop the existing database and user[¹]. `sudo -Hu postgres psql -c 'DROP DATABASE akkoma;';` `sudo -Hu postgres psql -c 'DROP USER akkoma;'` +6. Restore the database schema and akkoma role[¹] (replace the password with the one you find in the configuration file), `sudo -Hu postgres psql -c "CREATE USER akkoma WITH ENCRYPTED PASSWORD '';"` `sudo -Hu postgres psql -c "CREATE DATABASE akkoma OWNER akkoma;"`. 7. Now restore the Akkoma instance's data into the empty database schema[¹]: `sudo -Hu postgres pg_restore -d akkoma -v -1 ` -8. If you installed a newer Akkoma version, you should run `MIX_ENV=prod mix ecto.migrate`[³]. This task performs database migrations, if there were any. +8. If you installed a newer Akkoma version, you should run the database migrations `./bin/pleroma_ctl migrate`[²]. 9. Restart the Akkoma service. 10. Run `sudo -Hu postgres vacuumdb --all --analyze-in-stages`. This will quickly generate the statistics so that postgres can properly plan queries. -11. If setting up on a new server configure Nginx by using the `installation/akkoma.nginx` config sample or reference the Akkoma installation guide for your OS which contains the Nginx configuration instructions. +11. If setting up on a new server, configure Nginx by using the `installation/nginx/akkoma.nginx` configuration sample or reference the Akkoma installation guide which contains the Nginx configuration instructions. -[¹]: We assume the database name and user are both "akkoma". If not, you can find the correct name in your config files. -[²]: You can recreate the `config/setup_db.psql` by running the `mix pleroma.instance gen` task again. You can ignore most of the questions, but make the database user, name, and password the same as found in your backed up config file. This will also create a new `config/generated_config.exs` file which you may delete as it is not needed. -[³]: Prefix with `MIX_ENV=prod` to run it using the production config file. +[¹]: We assume the database name and user are both "akkoma". If not, you can find the correct name in your configuration files. +[²]: If you have a from source installation, the command is `MIX_ENV=prod mix ecto.migrate`. Note that we prefix with `MIX_ENV=prod` to use the `config/prod.secret.exs` configuration file. ## Remove From 394701269175a7c807e93430ee9c0b8ddb4bcd85 Mon Sep 17 00:00:00 2001 From: ilja Date: Mon, 29 May 2023 08:35:27 +0200 Subject: [PATCH 2/2] Fix warnings There were two warnings, these are now fixed. I moved the fonts folder into the css folder. Antother option was to change the relative path, but it seems that after changing it in the css file, the path got changed back when rebuilding the site. Maybe it needs to be changed somewhere else, idk, this worked. --- docs/docs/configuration/storing_remote_media.md | 2 +- docs/docs/{ => css}/fonts/Tiresias_Infofont.ttf | Bin docs/docs/{ => css}/fonts/Tiresias_PCfont.ttf | Bin 3 files changed, 1 insertion(+), 1 deletion(-) rename docs/docs/{ => css}/fonts/Tiresias_Infofont.ttf (100%) rename docs/docs/{ => css}/fonts/Tiresias_PCfont.ttf (100%) diff --git a/docs/docs/configuration/storing_remote_media.md b/docs/docs/configuration/storing_remote_media.md index deb1651b8..a0f099a87 100644 --- a/docs/docs/configuration/storing_remote_media.md +++ b/docs/docs/configuration/storing_remote_media.md @@ -6,7 +6,7 @@ as soon as the post is received by your instance. ## Nginx -The following are excerpts from the [suggested nginx config](../../../installation/nginx/akkoma.nginx) that demonstrates the necessary config for the media proxy to work. +The following are excerpts from the [suggested nginx config](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/installation/nginx/akkoma.nginx) that demonstrates the necessary config for the media proxy to work. A `proxy_cache_path` must be defined, for example: diff --git a/docs/docs/fonts/Tiresias_Infofont.ttf b/docs/docs/css/fonts/Tiresias_Infofont.ttf similarity index 100% rename from docs/docs/fonts/Tiresias_Infofont.ttf rename to docs/docs/css/fonts/Tiresias_Infofont.ttf diff --git a/docs/docs/fonts/Tiresias_PCfont.ttf b/docs/docs/css/fonts/Tiresias_PCfont.ttf similarity index 100% rename from docs/docs/fonts/Tiresias_PCfont.ttf rename to docs/docs/css/fonts/Tiresias_PCfont.ttf