Data Backup
MongoDB Backup
To backup MongoDB you can use the mongodump command to produce a dump in BSON format. E.g.:
mongodump --out=</backup/mongodump> --db=<dbname>
The dump can then be copied to a safe location.
As an alternative, the MongoDB data folder could be backed up directly using low level utilities (e.g. cp, rsync or cloud storage snapshots). In this case, it's important to lock the database before doing the backup. For further information on this, please refer to the MongoDB backup documentation.
Image Store Backup
Mambo offers three possible backends for storing images which are configured with the "storage.type" option in the mambo.properties configuration file:
- MongoDB storage
If the storage uses MongoDB there's nothing to backup explicitly as the images would already be backed up as part of the MongoDB backup. - AWS S3 storage
If the images are stored in AWS S3 they can be backed up with AWS Backup. - Local filesystem storage
If the images are stored in a folder in the local filesystem, this folder can be copied to a backup location using standard system utilities such as rsync. E.g.:rsync -a </storage/upload/dir> </image/backup/path>
The location of the local image store is configured with the "storage.upload.dir" option in the mambo.properties configuration file.
Restoring from a backup
Before starting a restore from a backup you must stop all tomcat instances.
Restoring the database
Before restoring MongoDB you must drop the existing database:
mongo <dbname> --eval "db.dropDatabase()"
Then you can restore MongoDB from the dump:
mongorestore --db <dbname> </backup/mongodump>
Restoring Images
If the image store is configured to use Local file system storage, it can be restored by copying the images from the backup to the "storage.upload.dir" folder configured in the mambo.properties file. E.g.:
rsync -a </image/backup/path> </storage/upload/dir>
If the image store is configured as AWS S3 you can follow the AWS Backup documentation to restore data. Alternatively, if the image store uses MongoDB storage there is no need to explicitly restore the data as it would have already been restored by the mongorestore command.
At this point the restore is complete and you can restart all tomcat instances.
0 Comments