Method, electronic device, and computer program product for deleting backup data
Embodiments of the present disclosure provide a method, an electronic device, and a computer program product for deleting backup data. The method includes determining a set of non-backup time periods for an object based on a set of backup time periods for the object. The method further includes selecting a subset of non-backup time periods from the set of non-backup time periods on the basis of a time length. The method further includes deleting backup data of the object in the subset of non-backup time periods. By the embodiments of the present disclosure, a suitable time period can be selected, and unnecessary backup data is effectively deleted from the selected time period, thus improving the success rate of deletion of backup data.
1. A method of deleting backup data, comprising:
determining a set of non-backup time periods for an object based on a set of backup time periods for the object;
selecting a subset of non-backup time periods from the set of non-backup time periods based on a time length; and
deleting backup data of the object in the subset of non-backup time periods.
2. The method according to claim 1 , wherein selecting a subset of non-backup time periods from the set of non-backup time periods based on a time length comprises:
sorting the time periods in the set of non-backup time periods based on the time length; and
selecting, based on the sorting, a threshold number of time periods as the subset of non-backup time periods.
3. The method according to claim 1 , wherein deleting the backup data of the object in the subset of non-backup time periods comprises:
sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence.
4. The method according to claim 3 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
selecting a first time period from the subset of non-backup time periods, the first time period being the earliest time period in the subset of non-backup time periods; and
deleting the backup data in the first time period.
5. The method according to claim 4 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
determining whether the deletion of the backup data in the first time period was successful; and
in response to determining that the deletion of the backup data in the first time period failed, determining whether a number of deletions has reached a deletion threshold.
6. The method according to claim 5 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
in response to determining that the number of deletions has not reached the deletion threshold, selecting a second time period from the subset of non-backup time periods, the second time period being after the first time period and associated with the number of deletions; and
deleting the backup data in the second time period.
7. The method according to claim 5 , further comprising:
in response to determining that the number of deletions has reached the deletion threshold, stopping the deletion of the backup data; and
sending a notification of the failed deletion of the backup data to a user.
8. The method according to claim 5 , wherein deleting the backup data comprises:
attempting again to delete the backup data of which the deletion failed previously.
9. The method according to claim 1 , further comprising:
backing up data other than the backup data in the set of backup time periods.
10. The method according to claim 9 , further comprising:
if the backup is completed in advance of a certain time period in the set of backup time periods, adding the length of time for early completion to a corresponding time period in the set of non-backup time periods.
11. An electronic device, comprising:
a processor; and
a memory coupled to the processor and having instructions stored therein, which when executed by the processor, cause the device to perform actions, the actions comprising:
determining a set of non-backup time periods for an object based on a set of backup time periods for the object;
selecting a subset of non-backup time periods from the set of non-backup time periods based on a time length; and
deleting backup data of the object in the subset of non-backup time periods.
12. The electronic device according to claim 11 , wherein selecting a subset of non-backup time periods from the set of non-backup time periods based on a time length comprises:
sorting the time periods in the set of non-backup time periods based on the time length; and
selecting, based on the sorting, a threshold number of time periods as the subset of non-backup time periods.
13. The electronic device according to claim 11 , wherein deleting the backup data of the object in the subset of non-backup time periods comprises:
sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence.
14. The electronic device according to claim 13 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
selecting a first time period from the subset of non-backup time periods, the first time period being the earliest in the subset of non-backup time periods; and
deleting the backup data in the first time period.
15. The electronic device according to claim 14 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
determining whether the deletion of the backup data in the first time period was successful; and
in response to determining that the deletion of the backup data in the first time period failed, determining whether a number of deletions has reached a deletion threshold.
16. The electronic device according to claim 15 , wherein sequentially deleting the backup data in each time period of the subset of non-backup time periods according to a time sequence comprises:
in response to determining that the number of deletions has not reached the deletion threshold, selecting a second time period from the subset of non-backup time periods, the second time period being after the first time period and associated with the number of deletions; and
deleting the backup data in the second time period.
17. The electronic device according to claim 15 , wherein the actions further comprise:
in response to determining that the number of deletions has reached the deletion threshold, stopping the deletion of the backup data; and
sending a notification of the failed deletion of the backup data to a user.
18. The electronic device according to claim 15 , wherein deleting the backup data comprises:
attempting again to delete the backup data of which the deletion failed previously.
19. The electronic device according to claim 11 , wherein the actions further comprise:
backing up data other than the backup data in the set of backup time periods.
20. A non-transitory machine-readable medium having instructions stored therein, which when executed by a processor, cause the processor to perform actions, the actions comprising:
determining a set of non-backup time periods for an object based on a set of backup time periods for the object;
selecting a subset of non-backup time periods from the set of non-backup time periods based on a time length; and
deleting backup data of the object in the subset of non-backup time periods.