V@no - 2021-09-30

This is a simple Python script that backup edited file before it's being overwritten on save.
It recreates a directory structure of original file in the backup folder and appends modification date of the original file to the end of filename (not date of the backup, file modification date).
i.e. file C:\blah\mycode.js will be backed up as D:\Backup\Notepad++\C\blah\mycode.js_20210928_221824.js
Because it copies file before NPP saves new data into it, you always will have a copy of the original file.
If variable backup_after_save set to True it will also backup current version of the file to the same backup directory.

Required PythonScript

Save this script as autobackup.py into the same directory where startup.py is (in portable NPP it's in Notepad++\plugins\PythonScript\scripts) and in Python Script configuration window set "Initialization" dropdown to "ATSTARTUP"

Change to your desired backup directory and other settings:

backup_dir = 'D:\\Backup\\Notepad++\\'; # backup directory, must have trailing slash
backup_before_save = True;              # backup original file before save with date/time in filename
backup_after_save = False;              # backup current file after it was saved (simple duplicate of current file)
backup_time_format = "_%Y%m%d_%H%M%S";  # date/time format 

Than in startup.py at the bottom add this line:

import autobackup # script's filename without extension
 

Last edit: V@no 2021-10-03