From 3e6283f651807458d39534d5bc0b8a0ea3cc9e3e Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Wed, 11 Aug 2021 23:27:07 +0300 Subject: [PATCH] Updated Backup (markdown) --- Backup.md | 86 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/Backup.md b/Backup.md index 2a7c204..fd418c4 100644 --- a/Backup.md +++ b/Backup.md @@ -7,11 +7,11 @@ Note: Do not run `docker-compose down` without verifying your docker-compose fil [docker-compose.yml](https://raw.githubusercontent.com/wekan/wekan/master/docker-compose.yml) This presumes your Wekan Docker is currently running with: -``` +```bash docker-compose up -d ``` Backup to directory dump: -``` +```bash docker stop wekan-app docker exec wekan-db rm -rf /data/dump docker exec wekan-db mongodump -o /data/dump @@ -21,7 +21,7 @@ docker start wekan-app Copy dump directory to other server or to your backup. # Restore Docker -``` +```bash docker stop wekan-app docker exec wekan-db rm -rf /data/dump docker cp dump wekan-db:/data/ @@ -30,41 +30,43 @@ docker start wekan-app ``` # Upgrade Docker Wekan version Note: Do not run `docker-compose down` without verifying your docker-compose file, it does not delete the data by default but caution is advised. Refer to https://docs.docker.com/compose/reference/down/. -``` +```bash docker-compose stop docker rm wekan-app ``` a) For example, if you in docker-compose.yml use `image: wekanteam/wekan` or `image: quay.io/wekan/wekan` for latest development version b) Or in docker-compose.yml change version tag, or use version tag like `image: wekanteam/wekan:v5.50` or `image: quay.io/wekan/wekan:v5.50` -``` +```bash docker-compose up -d ``` # Backup Wekan Snap to directory dump -``` +```bash sudo snap stop wekan.wekan export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan/current/lib/x86_64-linux-gnu export PATH="$PATH:/snap/wekan/current/bin" mongodump --port 27019 sudo snap get wekan > snap-settings.sh ``` +NOTE for Arch: See correct snap paths for Arch at https://github.com/wekan/wekan/issues/3941 + username is your /home/username -``` +```bash sudo chown username:username snap-settings.sh sudo snap start wekan.wekan ``` Modify snap-settings.sh so that it has commands like: -``` +```bash sudo snap set wekan root-url='http://localhost' ``` Set snap-settings.sh executeable: -``` +```bash chmod +x snap-settings.sh ``` # Restore Wekan Snap -``` +```bash sudo snap stop wekan.wekan export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan/current/lib/x86_64-linux-gnu export PATH="$PATH:/snap/wekan/current/bin" @@ -74,12 +76,12 @@ sudo snap start wekan.wekan ``` # Upgrade Snap manually immediately (usually it updates automatically) -``` +```bash sudo snap refresh ``` # Backup Wekan Gantt GPLv2 Snap to directory dump -``` +```bash sudo snap stop wekan-gantt-gpl.wekan export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan-gantt-gpl/current/lib/x86_64-linux-gnu export PATH="$PATH:/snap/wekan-gantt-gpl/current/bin" @@ -87,21 +89,21 @@ mongodump --port 27019 sudo snap get wekan-gantt-gpl > snap-settings.sh ``` username is your /home/username -``` +```bash sudo chown username:username snap-settings.sh sudo snap start wekan-gantt-gpl.wekan ``` Modify snap-settings.sh so that it has command like: -``` +```bash sudo snap set wekan-gantt-gpl root-url='http://localhost' ``` Set snap-settings.sh executeable: -``` +```bash chmod +x snap-settings.sh ``` # Restore Wekan Gantt GPLv2 Snap -``` +```bash sudo snap stop wekan-gantt-gpl.wekan export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan-gantt-gpl/current/lib/x86_64-linux-gnu export PATH="$PATH:/snap/wekan-gantt-gpl/current/bin" @@ -141,25 +143,25 @@ Backups are created to subdirectories of `/root/backups/`. Cron is used to schedule backups, for example once a day. 1. To add bash scripts, you change to root user with this command, and your sudo or root password. -``` +```bash sudo su ``` 2. Use nano editor for editing cron. If you don't have it installed, type: -``` +```bash apt install nano ``` 3. Then we set text editor to be nano. Otherwise it probably uses vi, that is harder to use. -``` +```bash export EDITOR=nano ``` 4. Now we start editing cron scheduler. -``` +```bash crontab -e ``` For more info how to make cron time, see https://crontab.guru In this example, we set backups every day at 04:00, then it runs backup.sh script, and saves output of the backup commands to the bottom of textfile backup.log.txt -``` +```bash # m h dom mon dow command 0 4 * * * /root/backup.sh >> /root/backup.log.txt 2>&1 ``` @@ -172,7 +174,7 @@ In this example, we set backups every day at 04:00, then it runs backup.sh scrip This is content of `backup.sh` script. It runs all the other backup scripts. If you do not need to backup rocketchat or website, or do not need to use rclone, you don't need to add those command lines at all. -``` +```bash cd /root ./backup-wekan.sh ./backup-rocketchat.sh @@ -182,7 +184,7 @@ rclone move backups cloudname:backup.example.com More about rclone: /root/rclone-ls-all.sh , shows directory contests at cloud: -``` +```bash rclone lsd cloudname: ``` In this example, cron does run backup scripts as root. @@ -196,14 +198,14 @@ You can also list current cron with command `crontab -l`. If you like to backup Wekan snap settings with this command, then it only works with sudo at front, or as a root user without sudo at front. -``` +```bash sudo snap get wekan > snap-settings.txt ``` This below is backup script for backing up Wekan. /root/backup-wekan.sh -``` +```bash #!/bin/bash makeDump() @@ -266,9 +268,9 @@ fi # Starts makeDump -``` +```bash /root/backup-rocketchat.sh -``` +```bash #!/bin/bash makeDump() @@ -315,7 +317,7 @@ fi makeDump ``` /root/backup-website.sh -``` +```bash #!/bin/bash makeDump() @@ -359,7 +361,7 @@ fi makeDump ``` /var/snap/wekan/common/Caddyfile -``` +```bash chat.example.com { proxy / localhost:3000 { websocket @@ -433,7 +435,7 @@ Note: Do mongodump/mongorestore only when Wekan is stopped: wekan.wekan (Snap) o Wekan web UI Import/Export JSON does not have all content currently. To upgrade from old Wekan version, use mongodump/mongorestore to newest Wekan, like described below. To import big JSON file, on Linux you can use xclip to copy textfile to clipboard: -``` +```bash sudo apt-get install xclip cat board.json | xclip -se c ``` @@ -450,16 +452,16 @@ You could use [daff](https://github.com/paulfitz/daff) to compare tables. ## Using Snap Mongo commands on your bash CLI Add to your `~/.bashrc` -``` +```bash export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan/current/lib/x86_64-linux-gnu export PATH="$PATH:/snap/wekan/current/bin" ``` Then you can backup: -``` +```bash mongodump --port 27019 ``` And restore: -``` +```bash mongorestore --drop --port 27019 ``` @@ -484,7 +486,7 @@ Originally from https://github.com/wekan/wekan-snap/issues/62#issuecomment-47062 ## Backup wekan-backup.sh -``` +```bash #!/bin/bash export LC_ALL=C export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan/current/lib/x86_64-linux-gnu @@ -535,7 +537,7 @@ else fi ``` wekan-restore.sh -``` +```bash #!/bin/bash export LC_ALL=C export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/wekan/current/lib/x86_64-linux-gnu @@ -578,7 +580,7 @@ makesRestore $1 ## Backup script for MongoDB Data, if running Snap MongoDB at port 27019 -```sh +```bash #!/bin/bash makeDump() @@ -626,7 +628,7 @@ makeDump ## Restore script for MongoDB Data, if running Snap MongoDB at port 27019 with a tar.gz archive. -```sh +```bash #!/bin/bash makesRestore() @@ -702,7 +704,7 @@ Download Wekan grain with arrow down download button to .zip file. You can resto If those [Backup](https://github.com/wekan/wekan/wiki/Backup) ways are not easily found at [Cloudron](https://github.com/wekan/wekan/wiki/Cloudron), one way is to install [Redash](https://redash.io/) and then backup this way: Redash works with this kind of queries: -``` +```json { "collection": "accountSettings", "query": { @@ -719,7 +721,7 @@ Redash works with this kind of queries: So: 1) Create this kind of query: -``` +```json { "collection": "boards" } @@ -731,14 +733,14 @@ Later when you modify query, you can remove text like boards with double-click-w 3) Click Execute. This will cache query for use with REST API. -4) Click at right top [...] => Show API key +4) Click at right top `[...]` => `Show API key` It looks like this: https://redash.example.com/api/queries/1/results.json?api_key=... 5) Only when saving first collection/table, Save API key to text file script like this `dl.sh` -``` +```bash #!/bin/bash # Example: ./dl.sh boards @@ -749,7 +751,7 @@ curl -o $1.json $APIKEY ``` 6) Run save script like: -``` +```bash ./dl.sh boards ``` Note: 1) Save 2) Execute => webbrowser can give this kind of timeout,