diff --git a/Repair-MongoDB.md b/Repair-MongoDB.md index db4ca06..5e2a0ea 100644 --- a/Repair-MongoDB.md +++ b/Repair-MongoDB.md @@ -1,6 +1,6 @@ -Some customer of [WeKan Commercial Support](https://wekan.team/commercial-support/) ordered repair of WeKan MongoDB database at Univention appliance. Docker containers were all the time crashing and restarting. Here are commands that were used while repairing. +Some customer of [WeKan Commercial Support](https://wekan.team/commercial-support/) ordered restore and repair of WeKan MongoDB database at UCS appliance. Docker containers were all the time crashing and restarting. Here are commands that were used while repairing. -1. SSH to Univention as root. +1. SSH to UCS appliance as root: ``` ssh root@192.168.0.100 ``` @@ -14,7 +14,7 @@ fdisk -l /dev/sdc fdisk -l /dev/sdd ``` -2. If external USB drive has NTFS file format, install NTFS support to Linux: +2. If external USB drive has NTFS file format, and mount complains about not having NTFS support, install NTFS support to Linux: ``` apt install ntfs-3g ``` @@ -38,44 +38,71 @@ root@ucs:/mnt/wekan/data/db# locate WiredTiger.wt /mnt/wekan/data/db/WiredTiger.wt /var/lib/univention-appcenter/apps/wekan/data/db/WiredTiger.wt ``` -6. Find mongod command: +6. Change to newly installed MongoDB data directory: +``` +cd /var/lib/univention-appcenter/apps/wekan/data/db/ +``` +7. Look at directory files owner permissions: +``` +ls -lah +``` +There could be like this: +``` +-rw-r--r-- 1 tss tss 1004 Jan 25 13:09 WiredTiger.turtle +-rw-r--r-- 1 tss tss 392K Jan 25 13:09 WiredTiger.wt +``` +8. Move that probably empty newly installed MongoDB data elsewhere: +``` +mkdir /root/new-empty-wekan-data +mv * /root/new-empty-wekan-data +``` +9. Copy MongoDB raw database files from USB harddrive to docker container directory: +``` +root@ucs-bdc:/var/lib/univention-appcenter/apps/wekan/data/db# cp -pR /mnt/wekan/data/db/* . +``` +10. Like looked at step 7, change file owner permissions to be correct, and change directory +``` +chown -R tss:tss * +cd /root +``` +11. Find mongod command: ``` locate /usr/bin/mongod ``` -7. Repair Docker WeKan with version of Docker MongoDB that WeKan uses, change mongod path to below. Repairing logged to textfile. +12. Repair Docker WeKan with version of Docker MongoDB that WeKan uses, change mongod path to below. Repairing logged to textfile. ``` root@ucs:~# /var/lib/docker/overlay2/7b58483a16a2f67ee50486c00ec669940f7a95d460ee8188966fee0096e81fa2/diff/usr/bin/mongod --dbpath "/var/lib/univention-appcenter/apps/wekan/data/db" --repair >> repairlog.txt ``` -8. Look what containers are running: +13. Look what containers are running: ``` docker ps ``` -9. Look what containers are not running: +14. Look what containers are not running: ``` docker ps -a ``` -10. Start MongoDB first: +15. Start MongoDB first: ``` docker start wekan-db ``` -11. Look what happends at MongoDB container: +16. Look what happends at MongoDB container: ``` docker logs wekan-db ``` -12. Start WeKan next. +17. Start WeKan next. ``` docker start wekan-app ``` -11. Look what happends at MongoDB container. +18. Look what happends at MongoDB container. ``` docker logs wekan-app ``` -12. Check are both wekan-db and wekan-app containers running, and not restarting: +19. Check are both wekan-db and wekan-app containers running, and not restarting: ``` docker ps ``` -13. Try to login to WeKan with webbrowser. -14. Backup WeKan database now after repair: +20. Try to login to WeKan with webbrowser. +21. Backup WeKan database now after repair: ``` docker exec -it wekan-db bash cd /data @@ -87,24 +114,21 @@ zip -r wekan-backup-2022-01-01.zip dump ``` Now backup is at wekan-backup-2022-01-01.zip file. -15. Transfer file to your local computer with scp: +22. At your local computer terminal (not at UCS server), transfer file to your local computer with scp: ``` scp root@192.168.0.100:/root/wekan-backup-2022-01-01.zip . ``` -16. Copy backup to external USB harddrive: +23. Copy backup to external USB harddrive, change YEAR-MONTH-DATE-TIME-HERE to current date and time: ``` -cp /root/wekan-backup-2022-01-01.zip /mnt/ +cp /root/wekan-backup-YEAR-MONTH-DATE-TIME-HERE.zip /mnt/ ``` -17. Look what drives are mounted: +24. Look what drives are mounted: ``` df -h ``` -18. Sync and save unwritted data to disk, and unmount external USB harddrive safely: +25. Sync and save unwritted data to disk, and unmount external USB harddrive safely: ``` sync umount /mnt ``` -19. Remove external USB harddisk from server. - - - +26. Remove external USB harddisk from server. \ No newline at end of file