Use your Google Account to automatically back up app data and settings including Wi-Fi passwords and files stored by certain apps.
Use HTC Sync Manager to import music, photos, and videos from HTC One M9 to your computer. You can also sync locally stored contacts, calendar events, and playlists between HTC One M9 and your computer.
Likewise, HTC Sync Manager is a good alternative if you don't want to back up your accounts, settings, and other personal content to the cloud. You can use it to create backups of HTC One M9 on your computer.
If you want, you can separately back up your data or files.
Some apps allow you to back up data to the phone storage or storage card so you can easily restore them after a factory reset. Just make sure not to erase the phone storage or storage card when you do a factory reset.