Browse Source

Merge branch 'j7back'

Add utilities to manually back up jovian platform.
DricomDragon 5 years ago
parent
commit
4735436245

+ 83 - 0
Guides/backup.md

@@ -0,0 +1,83 @@
+# Backup
+
+How to back up server services.
+
+## Prepare
+
+```sql
+CREATE ROLE backup WITH
+    NOSUPERUSER
+    NOCREATEDB
+    NOCREATEROLE 
+    PASSWORD 'tropcool'
+    LOGIN
+    ;
+```
+
+### Probably does not work
+Add in the file `pg_hba.conf` :
+```
+local all backup trust
+```
+
+Reload with `SELECT pg_reload_conf();`.
+
+### Probably works
+
+With _postgres_ : `GRANT SELECT ON ALL TABLES IN SCHEMA public TO backup;`
+
+Connect with `sudo -u postgres psql --username=backup --host localhost --dbname=kanboard_db`
+
+`pg_dump kanboard_db --username=backup --host=localhost > dumpfile.test`
+
+Does not work because backup can't access sequences.
+
+## Backup process
+
+### Disable websites
+
+Through _SSH_ on server
+
+```sh
+sudo a2dissite \
+kanboard.jovian-hersemeule.eu kanboard.jovian-hersemeule.eu-le-ssl \
+wiki.jovian-hersemeule.eu wiki.jovian-hersemeule.eu-le-ssl \
+gogs.jovian-hersemeule.eu gogs.jovian-hersemeule.eu-le-ssl ;
+sudo systemctl reload apache2 ;
+```
+
+### Backup local machine
+
+Through _SSH_ on server
+
+```sh
+cd /home/jovian/GitWork/DricomDragon/JovianLinux/ServerScripts/Backup/ ;
+git pull ;
+./j7backalllocal
+```
+
+### Retrieve backups
+
+On local machine
+
+```sh
+cd /home/jovian/GitWork/DricomDragon/JovianLinux/ServerScripts/Backup/ ;
+git pull ;
+./j7retrieve
+```
+
+### Enable websites
+
+Through _SSH_ on server
+
+```sh
+sudo a2ensite \
+kanboard.jovian-hersemeule.eu kanboard.jovian-hersemeule.eu-le-ssl \
+wiki.jovian-hersemeule.eu wiki.jovian-hersemeule.eu-le-ssl \
+gogs.jovian-hersemeule.eu gogs.jovian-hersemeule.eu-le-ssl ;
+sudo systemctl reload apache2 ;
+```
+
+## Automate
+
+Use Jenkins.

+ 18 - 0
Guides/postgres.md

@@ -0,0 +1,18 @@
+# Postgres SQL
+
+Tips for using Postgres SQL.
+
+## Backup
+
+Create backup profile :
+
+```
+CREATE ROLE backup WITH 
+    NOSUPERUSER
+    NOCREATEDB
+    NOCREATEROLE 
+    LOGIN
+    PASSWORD 'IWantToBackUp';
+```
+
+Use `\du` to list roles.

+ 6 - 0
Guides/wiki.md

@@ -148,3 +148,9 @@ DROP ROLE wiki_app ;
 ```
 sudo rm -r /var/www/mediawiki
 ```
+
+## Backup Wiki
+
+[https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki](Backing up a wiki)
+
+See the `ServerScripts/Backup` folder.

+ 30 - 0
ServerScripts/Backup/j7backalllocal

@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# Script to backup jovian web platform locally
+
+echo 'Backing up jovian platform ...'
+
+# Backup all postgres just in case
+echo 'Backing up PostgreSQL ...'
+sudo -u postgres pg_dumpall > /home/jovian/Local/Backup/Postgres/dumpfile
+echo 'PostgreSQL done.'
+
+echo 'Backing up GOGS ...'
+sudo -u gituser /home/gituser/gogs/gogs backup --target /home/gituser/
+sudo mv /home/gituser/gogs-backup-2* /home/jovian/Local/Backup/Gogs/
+sudo chown jovian:jovian /home/jovian/Local/Backup/Gogs/gogs-backup-2*
+echo 'GOGS done.'
+
+echo 'Backing up KANBOARD ...'
+sudo -u postgres pg_dump kanboard_db > /home/jovian/Local/Backup/Postgres/kanboard_dumpfile
+echo 'KANBOARD done.'
+
+echo 'Backing up WIKI ...'
+echo '> wiki db ...'
+sudo -u postgres pg_dump wiki_db > /home/jovian/Local/Backup/Postgres/wiki_dumpfile
+
+echo '> wiki files ...'
+tar chf /home/jovian/Local/Backup/Wiki/mediawiki.tar /var/www/mediawiki
+echo 'WIKI done.'
+
+echo 'Platform saved.'

+ 9 - 0
ServerScripts/Backup/j7backallssh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Script to backup jovian web platform
+
+echo 'Backing up jovian platform ...'
+
+ssh -p 7025 jovian-hersemeule.eu 'pg_dumpall --username=backup --no-password > /home/jovian/Local/Backup/Postgres/dumpfile'
+
+echo 'End'

+ 9 - 0
ServerScripts/Backup/j7backretrieve

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Script to retrieve backups from jovian web platform
+
+echo 'Retrieving backups from jovian platform ...'
+
+rsync -parv jovian-hersemeule.eu:~/Local/Backup/ ~/Local/Backup/ -e "ssh -p 7025"
+
+echo 'End'