Simple backup scenario

To save files and periodically back them up, it is best to use an archiving tool with its own directory list for saving, so as not to enter the same commands constantly.

SEB (Simple and Efficient Backup) is a script written in Script/PHP that automates frequent data backups.

How the script works

The main thing to add to the archiver:

  1. A table with a list of files or directories for regular backups.
  2. Name of the archive automatically built according to date and time.
  3. Command with 7-Zip or PKZip options.

The program then includes the following code...

A table listing files or directories.

array saving = [
....noms séparés par une virgule
]

PKZip only: In the case of a directory, an asterisk slash is used. Example:

w:/scriptol.com/     // pour 7-zip
mais
w:/scriptol.com/*     // pour pkzip
Automatic creation of archive name with order: year, month, day, hour, minute.
This file name will be merged with the device name and possibly the target directory and passed to the command line .
text newdir = "backup-" + Date("Y-M-d-H-i") 

Create an order for the archiver .

 text command = "7z a -tzip $target "
for text t in saving
command + t + " "
/for

Command execution:

exec(command)  

The directory and file structure will be stored in the archive.

Using the program

Extract content from backup to disk root. The script will be available on the command line in the/seb/directory.

Place 7z.exe and 7z.dll in a directory that takes into account the PATH variable, which allows you to run these programs from any directory .

First you need to edit the script code, either in the original seb.sol, in php in seb.php, to give a list of files and directories to back up.

To do this, modify the contents of the save table as described above.

array saving = [ votre liste de répertoire séparés par une virgule ]

Select a time zone and assign it to the following function:

date_default_timezone_set("US/Central") 

List of time zones - in the PHP manual. Replace US/Central with the city.

Then you can execute the script. Target drive or directory specified.

An example of a command in Script:

solp seb d:

Example of a command in PHP:

php seb.php d:/temp/

If/temp does not exist on disk, it will be created.

Restore a backup

Perhaps there will come a day when you accidentally lose, or because of a virus, all or part of your data.

You can then rebuild the directory structure along with the files they contain using the command:

7z e nomarchive.zip   

If you just want to get a file or directory, you can use the archive manager to select files and destinations through the graphical interface.

In Windows 7, you can open the zip file as a folder and move the directory or file to the file system directory.
Note that you can also create a "compressed folder," which is actually a zip archive, and move files and directories there.

Download SEB Archive

This script is free and licensed by MIT.

In the second part, we will look at how to perform an incremental backup by updating the same file using the archiver.