Backups should be handled by an external process, otherwise, your script also needs to take into account:
- Number of backups to retain and cleaning up old versions
- Monitoring of backups. What if backing up fails?
- The script itself can tamper with the backups unintentionally?
Speaking from (bad) experience