BoiseBackup

From Iseborn Wiki
Jump to: navigation, search

boiseBackup is a two-part PHP script for taking backups of the files on a web site. As usual, I created this because I needed it myself on iseborn.eu, but I have tried to keep it general so that it can be used by anyone on their sites (no guarantees for that though).

Security statement

If you install this on your site, then everyone that can access it can also download everything on your site!

It is important to understand that by running this script from a web browser, you circumvents all of the usual authorization methods for individual folders and files on the site, since it is a PHP script that access the files.

If you do not care about if your worst enemy, or a complete stranger for that matter, gets hold of every file on your site (pictures, static HTML files, secret diaries, ...), then you do not need to worry. Most people however, either have at least some stuff that they, for one reason or another, do not want to make public. And there is also another reason to keep this script away from the public: When you make a backup, the resulting backup file (which, of course, can get quite large for the complete site) is stored on the server until you remove it. This means that a vandal could just keep making backups until you run out of storage space, which could (depending on your web server) cause the site to crash, or possibly cost you money for exceeding your storage quota.

What I am getting at is that you will probably want to protect this script so that only you (or whomever you like) can run it. This is of course even more important for the "connector" script which you will learn more about later.

I use HTAccess for this. I will try to add some information about how to do that at a later time, but you can easily find it on the internet.

Installation

Usage

There are two main parts of the backup page. The first (top-most) is the "Backup set" section where you set up and perform backups, and the second (at the bottom) is the "Old backup files" section where you can delete old backup files from the server.

The Backup set section

This is where you set up a "backup set" and perform the actual backup.

A backup set is a selection of directories and files on the server that you you want to back up, and can optionally (and probably want to) save so that you can easily use it again at another time.

Selecting a backup set

The first thing to do here is to select the backup set that you want to back up. If you have stored it earlier, you can just select it from the top-most drop-down list. If not, select "A new backup set" and choose the files and directories to back up this time.

The Description field is only used if you want to store the new backup set for future use. What you see in the drop-down list is the name of the set followed by the description you provided earlier. So fill this out if you intend to store the backup set, otherwise you just ignore it.

Backup now

If you selected an existing backup set, you can just click the "Backup now" button to create the backup file. If not, you need to look at the next section to see how to select which files to back up first.

Clicking the "Backup now" button will create a zip file with all the selected files and directories. The text field under the button will then show the status of the zip operation, and if it was successful, you will also get a link for downloading the zip file to your computer (where you can chose where to store it for safe-keeping).

If you want, you can specify a name here for the zip file, but the recommended usage is to leave the file name field empty, which will generate a file name from the template.

Selecting files and folders to back up

Roughly in the middle of this section there are two list boxes, side by side. The left list shows every folder and file on the web site, and the right list shows the folders and files that you have selected to be backed up in the current backup set.

You select files and folders to back up by checking the corresponding check boxes in the "Files on server" list. When you check or uncheck anything there, you will see the corresponding change in the "Files to backup" list.

The "Files to backup" list is an overview of what will be backed up when you click the "Backup now" button. File names with a slash ("/") at the end is a directory, and signifies that the whole directory will be backed up.

Zip file name pattern

Rather than naming a new backup zip file explicitly, you can use this field to enter a pattern for how to name the file.

The default pattern is "$SET$_%Y%m%d_%H%M%S", which will name the zip file as the name of the backup set, followed by the date and time when it was created. For example "My_Set_20130620_214710.zip".

It is recommended to use the default pattern, but if you want to change it, the pattern is parsed through strftime after replacing any occurrence of $SET$ with the name of the current backup set.

The "Test the pattern" button will show you the name that would be used for the backup file if you had clicked the "Backup now" button instead. Note though, that this will likely not be the exact name of the backup file if you click "Backup now" directly afterwards, since the default file name pattern contains the clock second.

This pattern is only used if you leave the "Backup now as" text field empty.

Save and Discard changes

At the bottom of this section there are three buttons; "Save changes", "Discard changes" and "Save as".

The first two buttons are activated if you have selected an existing backup set, and have made any changes to it. Clicking "Discard changes" will restore the backup settings to the stored version. Clicking "Save settings" will save the changes you have made to the stored backup set.

Clicking "Save as" will save the current backup set in the name provided directly after it, meaning that you can both use it to simly copy an existing backup set, and to create an entirely new backup set.

Please note that when naming a new backup set, you should consider that the name, by default, is used as the prefix of the zip file name pattern for the backup files. The point being that it should be a text string that is valid as a partial file name on the operating system that you intend to save your backups to (to avoid problems later on).

The Old backup files section

This section is just a list of old backup files stored at the server, and buttons to remove some or all of them.

There is no point in keeping the old backup files on the server. I just did not want to remove them automatically in case something should go wrong with the transfer. But unless you are really tight on storage space, you can just let the new backups lie there for a while and then delete all of them when you fell like it.

The list shows every file in the backup storage directory. You can select one or more individual files by clicking on them (shift/ctrl-click works as usual for multi-select) in the list, and the buttons "Select all" and "De-select all" should be self-explanatory.

The "Delete selected" will delete all the selected files immediately. There is no point in asking for confirmation since there is no point in keeping these files.

The recommended usage is to just click "Select all" and then "Delete selected".