ApsaraDB for MongoDB retains backup files for 7 days by default. To protect your data beyond that window — whether you need a longer rolling history, want backups to survive after an instance is released, or need an offline copy — choose one of the three methods described in this topic.
Choose a method
| Situation | Method |
|---|---|
| The instance is running and you want a longer rolling backup history | Method 1: Extend the backup retention period |
| The instance is running and you need backups to persist after it is released | Method 2: Configure the backup retention policy after an instance is released |
| The instance uses local disks and MongoDB 4.2 or earlier, and you need an offline copy | Method 3: Download backup files |
Method 1: Extend the backup retention period
Increase the backup retention period so that a longer window of data is available for restore.
Extending the retention period keeps more backup files, which increases backup storage fees.
Extend the retention period
-
Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the region where the instance resides, and then click the instance ID.
-
In the left-side navigation pane, click Backup and Restoration.
-
Click Backup Settings.
-
In the Backup Settings panel, increase the values of Full Backup Retention Period (Days) and Log Backup Retention Period (Days). For example, change the backup retention period from 7 days to 30 days.
The Log Backup Retention Period (Days) value cannot exceed the Full Backup Retention Period (Days) value. For other backup settings, see Configure automatic backup for an ApsaraDB for MongoDB instance.
-
Click OK.
Method 2: Configure the backup retention policy after an instance is released
Configure a policy that controls what happens to backup sets when an instance is released. Backup sets are kept in the recycle bin, where you can restore data or migrate it to a new instance.
Prerequisites
Before you begin, ensure that you have:
-
A replica set or sharded cluster instance
-
An instance that uses Enterprise SSDs (ESSDs) for data storage
Configure the policy
-
Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the region where the instance resides, and then click the instance ID.
-
In the left-side navigation pane, click Backup and Restoration.
-
Click Backup Settings.
-
In the Backup Settings panel, set the Backup Retention Policy parameter. Choose the policy that matches your needs:
Policy What happens when the instance is released Delete all backup sets when you release the instance For the first 7 days, the most recent backup set remains visible in the recycle bin so you can migrate data to a new instance before it is removed. Automatically back up data when you release the instance and retain the backup set for the instance for a long time The most recent backup set is retained long-term and remains accessible in the recycle bin. You can migrate data to a new instance. Automatically back up data when you release the instance and retain all backup sets for the instance for a long time All backup sets are retained long-term and remain accessible in the recycle bin. You can migrate data to a new instance. After the instance is released, go to the recycle bin to restore data or update the retention policy. For more information, see Recycle bin. For other backup settings, see Configure automatic backup for an ApsaraDB for MongoDB instance.
-
Click OK.
Method 3: Download backup files
Download backup files to your local computer or to an Elastic Compute Service (ECS) instance for long-term offline storage. For more information about ECS, see What is ECS?
Prerequisites
Before you begin, ensure that you have:
-
An instance running MongoDB 4.2 or an earlier major version
-
An instance that uses local disks for data storage
-
An instance that supports physical backup
Download the backup files
For step-by-step instructions, see Download backup files.
Next steps
-
To automate and fine-tune your backup schedule, see Configure automatic backup for an ApsaraDB for MongoDB instance.
-
To restore data from a backup set, see Recycle bin.