Skip to main content

Importance of Backup

Backup operation plays a vital role in terms of system security and data integrity:

Preventing Data Loss

Protects your data in case of system failure, hardware error, or accidentally performed deletion operations.

Quick Recovery

In case of possible data loss, you can quickly restore from backup and make your system operational in a short time.

Version Control

Thanks to backups taken at different times, you can store different versions of your system and revert when necessary.

Business Continuity

Ensures business continuity in critical systems and minimizes the impact of possible interruptions.

MongoDB Backup Operation

Apinizer works with Replica Set MongoDB database. This situation should be taken into account when taking backup from MongoDB server.

Backup Command

MongoDB database can be backed up using the following command:
mongodump
mongodump \
  --host=<PRIMARY_MONGODB_IP> \
  --port=<PRIMARY_MONGODB_PORT> \
  --authenticationDatabase admin \
  --username apinizer \
  --password <MONGO_PASSWORD> \
  --db <DATABASE_NAME> \
  --gzip \
  --archive=/home/apinizer/apinizer-backup--v<CURRENT_VERSION>--<BACKUP_DATE>--01.archive
Parameters:
ParameterTypeRequiredDescription
--hoststringYesIP address of Primary MongoDB server
--portnumberYesMongoDB port number
--authenticationDatabasestringNoAuthentication database (default: admin)
--usernamestringYesMongoDB username
--passwordstringYesMongoDB password
--dbstringYesDatabase name to be backed up
--gzipbooleanNoCompresses backup file
--archivestringYesPath and file name where backup file will be saved

Backup File Naming

It is recommended to use the date when backup was taken and Apinizer version information in backup file naming.
Recommended File Name Format: apinizer-backup--v<CURRENT_VERSION>--<BACKUP_DATE>--01.archiveThanks to this format:
  • It is easy to understand which backup belongs to which system version
  • Version incompatibilities are prevented in restore operations
  • Management of archived backups is facilitated

Excluding Collections

If application logs or audit logs that may take up high space are not desired to be included, they can be separated with this command:--excludeCollection apinizer_log --excludeCollection audit_eventHowever, this operation will lead to data not being backed up, so it is not recommended.

Backup Best Practices

Regular Backup

Take backups at regular intervals (daily, weekly)

Automation

Automate backup operations (cron job, scheduled task)

Store in Different Locations

Store backups in different physical locations

Testing

Regularly perform restore tests of backups

Version Information

Always include version information in backup files

Security

Store backup files securely and apply access control

Detailed Information

You can review the MongoDB documentation for detailed information.