Skip to the content.

Daily Folder Backup

A tiny Python script that automatically backs up a folder to a destination directory once a day, timestamped by date.

Features

Requirements

Install the dependency with:

pip install schedule

Configuration

Open the script and set the two path variables at the top:

source_dir = "/path/to/folder/to/back/up"
destination_dir = "/path/to/where/backups/go"

By default, the job runs daily at 12:00 (24-hour format). To change the time, edit this line:

schedule.every().day.at("12:00").do(...)

Usage

Run the script and leave it running (e.g. in a terminal, tmux/screen session, or as a background service):

python automatic_file_backup.py

Each day at the scheduled time, it will create a new folder inside destination_dir named after the current date, containing a full copy of source_dir.

How it works

  1. schedule checks every 60 seconds whether it’s time to run the backup job.
  2. When triggered, copy_folder_to_directionary() builds a destination path using today’s date.
  3. shutil.copytree recursively copies the source folder into that dated destination.
  4. If a folder for that date already exists, a FileExistsError is caught and a message is printed instead of overwriting or crashing.

Limitations & ideas for contribution