Skip to content

Database Backups

This guide outlines the steps for configuring automatic backups for your database using a Python script. While this step is optional, implementing a backup solution to safeguard your data is strongly advised.

Setup Instructions

Install Python: Ensure Python is installed on your system, any python 3.x or higher version should work.

Prepare the Script:

  • Locate and unzip the zip file containing Backup.py.

Configure the Script:

  • Open Backup.py with a text editor.
  • Set the source_folder to the path of your database directory.
  • Adjust target_folder to where you'd like your backups stored. It is recommended to use a different (physical or network) drive for the backups in case your main drive fails.
  • Specify max_backups to control the maximum number of backups to keep.
  • Define backup_interval to set how frequently (in seconds) the backups should occur.

Run the Script:

Execute the script from a terminal or command prompt:

python Backup.py

How It Works

  • The script creates a backup of the specified source_folder into the target_folder, appending a timestamp to the backup's folder name for easy identification.
  • Old backups are managed based on the max_backups setting, ensuring only the most recent backups are kept.
  • The script runs continuously, performing backups at intervals defined by backup_interval.

Customization Tips

Modify the backup_interval according to your backup frequency needs. For example, 60*60*24 for daily backups.

Notes

This script mainly serves as a basic data backup system, feel free to change it however you like. You may also want to consider using other more sophisticated data backup systems, such as Duplicati.