Whatever precautions you take, be prepared for catastrophes. Always have a backup ready to restore your site to its most current healthy state.
There are a few great Joomla extensions that automate the backup process. A very popular one is Akeeba Backup. It will backup all necessary files (all Joomla files and the database contents) to recover your site. Akeeba will allow you to restore the backup file to any location (not just to its original location).
This is how you install Akeeba and create a backup: