Backup
Importance of Backup
Backup operation plays a vital role in terms of system security and data integrity:
Protects your data in case of system failure, hardware error, or accidentally performed deletion operations.
In case of possible data loss, you can quickly restore from backup and make your system operational in a short time.
Thanks to backups taken at different times, you can store different versions of your system and revert when necessary.
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 \
--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:
| Parameter | Type | Required | Description |
|---|---|---|---|
--host | string | Yes | IP address of Primary MongoDB server |
--port | number | Yes | MongoDB port number |
--authenticationDatabase | string | No | Authentication database (default: admin) |
--username | string | Yes | MongoDB username |
--password | string | Yes | MongoDB password |
--db | string | Yes | Database name to be backed up |
--gzip | boolean | No | Compresses backup file |
--archive | string | Yes | Path 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.archive
Thanks 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_event
However, this operation will lead to data not being backed up, so it is not recommended.
Backup Best Practices
Take backups at regular intervals (daily, weekly)
Automate backup operations (cron job, scheduled task)
Store backups in different physical locations
Regularly perform restore tests of backups
Always include version information in backup files
Store backup files securely and apply access control
Detailed Information
You can review the MongoDB documentation for detailed information.