Snap: MongoDB Backup Fails


When trying to create a backup of the Rocket Chat instance on Snap using the command sudo snap run rocketchat-server.backupdb , the backup fails silently and the created .tar.gz is empty (except for an empty dump folder).
The error log (see below) indicates an issue with server selection/permission problems.

Steps to reproduce:

  1. Execute the command sudo snap run rocketchat-server.backupdb
  2. Wait for success message [+] A backup of your data can be found at /var/snap/rocketchat-server/common/backups/rocketchat_backup_<TIMESTAMP>.tar.gz
  3. Extract .tar.gz file or try to restore from the backed up file

Expected behavior:

Find the database in the created .tar.gz -file

Actual behavior:

The .tar.gz only extracts to an empty dump folder. No error message is displayed during the backup process, you can only find an error in the log created later on.

Server Setup Information:

  • Version of Rocket.Chat Server: 4.3.1
  • Operating System: Ubuntu 18.04.6 LTS
  • Deployment Method: Snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Active
  • NodeJS Version: v12.22.8
  • MongoDB Version: 4.2.17

Client Setup Information

  • Desktop App or Browser Version: NA
  • Operating System: NA

Additional context

Initially this backup was supposed to be used for migration to a new server. On the new server the restore fails with ls: cannot access '/var/snap/rocketchat-server/common/restore/dump/parties': No such file or directory (see e.g. #12931). After troubleshooting, it was apparent that the .tar.gz that was copied to the new server was empty.
On that note: please update your documentation concerning snaps under Snaps - Rocket.Chat Docs
There is no .tgz -file anymore and also it is missing the fact that the created .tar.gz now contain timestamps. The steps for the backup and restore process are therefore inconsistent.

[] Dumping database with “mongodump -d parties -o /var/snap/rocketchat-server/common/backup/dump” 2022-01-15T13:44:39.652+0000 Failed: can’t create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: localhost:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp: lookup localhost on [::1]:53: dial udp [::1]:53: socket: permission denied }, ] } [] Packing archive with “tar czvf /var/snap/rocketchat-server/common/backup/rocketchat_backup_20220115.1344.tar.gz /var/snap/rocketchat-server/common/backup/dump” dump/