Skip to main content

Day to day operation

When you are operating a drive, you have usual burden. A server may restart, may fail, the mongodb may stop ... So you have to start, stop, dump, transfer, suppress instances.

A utility has been created to handle these tasks : cnd-admin. The documentation is the following :

./cnd-admin [options] action instance

options :
--dry-run|--dryrun : Just show what would be done without doing
--db : the name of the db in mongo is different of instance
--dadudi : the database dump directory if not /data/dump

action may be :
all|-a : list all instance and there status
stop|-o : stop an instance
status|-u : status of an instance
dump|-d : dump an instance
start|-s : start an instance
disable|-i: stop and put an instance in cimetiere (/var/www/cimetiere)
drop|-r : drop the database. At your own risk.
help|-h : this text

To definitely stop an instance you should :
* stop it
* dump it
* disable it
* drop the database
So in one line :
./cnd-admin stop dump disable drop instance

When disabling, it takes the full directory of the
instance and moves it to a repository of dead instances
The instance is put in cimetiere, it also remove systemd file
as well as syslog corresponding configuration files

Hypothesis :
* instance and db have the same name !!! Beware not always the case !
* /data/dump is used to dump the db
* /data/dump/YYYY-MM-DD-instance/instance/json and bson files is used to dump the db
* /var/www/cimetiere is used to put the files of no more necessary instances

A full session

root@lybero4-backup:~# ./cnd-admin all
+--------------------------------------------------+
| INSTANCE | STATUS | VERSION |
|----------------------|---------------------------|
| octolib | OK | 4.0.5 |
| bpstest | OK | 5.2.1-beta |
| bps-test | OK | 5.2.0-beta |
| cintime | OK | 5.0.2-beta |
| course01 | DEAD | 4.0.5 |
| course02 | DEAD | 4.0.5 |
| course03 | DEAD | 4.0.5 |
| course04 | DEAD | 4.0.5 |
| course05 | DEAD | 4.0.5 |
| course06 | DEAD | 4.0.5 |
| course07 | DEAD | 4.0.5 |
| ab-live | OK | 5.1.2-beta |
| demo | OK | 5.0.2-beta |
| drive | OK | 5.0.2-beta |
| ee | OK | 5.0.2-beta |
| gedel | OK | 4.1.3 |
| gedelroom | OK | 4.1.3 |
| gedeltest | OK | 5.0.2-beta |
| grolandima | OK | 5.0.2-beta |
| baffadon | OK | 5.0.2-beta |
| rompion | OK | 5.2.1-beta |
| groufe | OK | 4.0.5 |
| trainer | OK | 4.0.5 |
| wowbank | OK | 5.0.2-beta |
+--------------------------------------------------+
root@lybero4-backup:~# ./cnd-admin stop dump groufe
systemctl stop groufe
mongodump --db groufe -o /data/dump/2022-05-05-groufe
2022-05-05T18:04:12.167+0200 writing groufe.Logs to
2022-05-05T18:04:12.171+0200 writing groufe.Users to
2022-05-05T18:04:12.171+0200 writing groufe.Notifs to
2022-05-05T18:04:12.171+0200 writing groufe.FileSets_deleted to
2022-05-05T18:04:12.187+0200 done dumping groufe.Users (6 documents)
2022-05-05T18:04:12.187+0200 writing groufe.Users_deleted to
2022-05-05T18:04:12.201+0200 done dumping groufe.Logs (53 documents)
2022-05-05T18:04:12.201+0200 writing groufe.Groups to
2022-05-05T18:04:12.210+0200 done dumping groufe.FileSets_deleted (5 documents)
2022-05-05T18:04:12.210+0200 writing groufe.Groups_deleted to
2022-05-05T18:04:12.211+0200 done dumping groufe.Users_deleted (4 documents)
2022-05-05T18:04:12.211+0200 writing groufe.Folders to
2022-05-05T18:04:12.220+0200 done dumping groufe.Groups_deleted (4 documents)
2022-05-05T18:04:12.220+0200 writing groufe.Config to
2022-05-05T18:04:12.226+0200 done dumping groufe.Notifs (5 documents)
2022-05-05T18:04:12.226+0200 writing groufe.FileSets to
2022-05-05T18:04:12.238+0200 done dumping groufe.Groups (4 documents)
2022-05-05T18:04:12.238+0200 writing groufe.Chunks to
2022-05-05T18:04:12.246+0200 done dumping groufe.Folders (2 documents)
2022-05-05T18:04:12.246+0200 writing groufe.Sessions to
2022-05-05T18:04:12.256+0200 done dumping groufe.FileSets (0 documents)
2022-05-05T18:04:12.256+0200 writing groufe.Passport.Sessions to
2022-05-05T18:04:12.256+0200 done dumping groufe.Chunks (0 documents)
2022-05-05T18:04:12.256+0200 done dumping groufe.Sessions (0 documents)
2022-05-05T18:04:12.257+0200 done dumping groufe.Passport.Sessions (0 documents)
2022-05-05T18:04:12.274+0200 done dumping groufe.Config (1 document)
root@lybero4-backup:~# ./cnd-admin start groufe
systemctl start groufe
root@lybero4-backup:~# ./cnd-admin log groufe
root@lybero4-backup:~# ./cnd-admin status groufe
systemctl status groufe
+ groufe.service - groufe
Loaded: loaded (/lib/systemd/system/groufe.service; enabled)
Active: active (running) since Thu 2022-05-05 18:04:30 CEST; 13s ago
Main PID: 18970 (node)
CGroup: /system.slice/groufe.service
+-18970 /usr/bin/node /var/www/html/Lynvictus/groufe/server.js

May 05 18:04:34 lybero4-backup groufe[18970]: Trying to connection to DB mongodb://localhost:27017/groufe
May 05 18:04:34 lybero4-backup groufe[18970]: Connection ok.
May 05 18:04:34 lybero4-backup groufe[18970]: configuration local strategy local.
May 05 18:04:34 lybero4-backup groufe[18970]: configuration authentication strategy google disabled.
May 05 18:04:34 lybero4-backup groufe[18970]: Lynvictus (groufe/4.0.5) HTTP daemon "standard" starting on port 3013.
May 05 18:04:34 lybero4-backup groufe[18970]: file /var/www/html/Lynvictus/4.0.5/ssl/server.key or /var/www/html/Lynvictus/4.0.5/ssl/ser...t found
May 05 18:04:34 lybero4-backup groufe[18970]: (Re)setting timers
May 05 18:04:34 lybero4-backup groufe[18970]: Clean all sessions every 5000 ms
May 05 18:04:34 lybero4-backup groufe[18970]: Sending not logged notifications by email 10000 ms
May 05 18:04:34 lybero4-backup groufe[18970]: Sending digest notifications by email every 84400000 ms
Hint: Some lines were ellipsized, use -l to show in full.

In some cases, the database name and the instance name are not the same. This is only a problem for the dump function and for the drop one. In this case, you can provide a different database name. Here the instance is dev, but the database name is test.

sudo ./cnd-admin --db test --dadudi /home/alaprevo/Source/lynvictus3/mongodump dump dev