See the article How to back up your iPhone, iPad, and iPod touch with iCloud - Apple Support
Automatically back up with iCloud Backup
Follow these steps to set up iCloud Backup to automatically back up your device each day:
- Make sure that iCloud Backup is turned on in Settings > [your name] > iCloud > iCloud Backup.
- Connect your device to a power source.
- Connect your device to a Wi-Fi network.
- Make sure that your device's screen is locked.
- If you get an alert says that you don't have enough iCloud storage space to complete the backup, follow the onscreen steps to buy more storage.
Note : if automatically back up with iCloud backup was always turned as on the photos were saved on iCloud , if not the photos can't be recovered unless you backed up somewhere else in Mac / pc  Backup methods for iPhone, iPad, and iPod touch - Apple Support
Then the data can be recovered .
Read Get help with iCloud Photos - Apple Support
What happens when I go over my iCloud storage limit?
If you exceed your iCloud storage limit, photos and videos won't upload to iCloud and your library won’t stay up to date across your devices. To continue using iCloud Photos, upgrade your storage plan or reduce the amount of storage that you're using.
Reduce the storage for iCloud Photos by deleting photos and videos that you don't want to keep from your iOS devices or on iCloud.com. Your device will immediately remove any photos and videos that you delete and they won't be available for recovery in your Recently Deleted album.
If you're out of storage, your devices won't back up to iCloud, and new photos, videos, documents, and your information won't stay up to date.