All-in-One Backup Script for all-inkl.com
Eiko WagenknechtAfter successfully migrating my websites to all-inkl.com, I discovered a lack of automated backup solutions. Since existing solutions didn’t meet my requirements, I decided to develop my own backup script in PHP—complete with useful features like automatic execution, email notifications, and storage management.
Table of Contents
About the Script
The resulting script backs up all sites and databases hosted on all-inkl.com and offers additional convenience features missing from other scripts.
Script Features
- Manual or automated execution: The script can be executed either manually by calling a URL or automatically via a cron job.
- Notifications: After each backup, the script provides information about the amount of data backed up and the storage space usage. Notification settings are configurable, allowing for alerts only in case of errors.
- Archiving options: Choose between fast (gzip) or small (bzip2) compression methods.
- Quota management: You can set a storage quota for backups. When the backup exceeds this limit, older files are automatically deleted.
- FTP support: The script can send data to an FTP server, either via SSL or unencrypted.
Script Configuration
The complete script is available for download (see below). Here are some important configuration sections:
// ########## START EDITING HERE ##########
// script settings
// -----------------------------------------------------------------------------
// use appropriate amount of memory and execution time. allowed values depend on
// your hoster (in this case probably all-inkl.com) and package.
$config["php"]["max_execution_time"] = 600; // seconds
$config["php"]["memory_limit"] = "256M"; // megabytes
// general backup settings
// -----------------------------------------------------------------------------
// the target directory is relative to the root of the webspace and has to be
// entered without a trailing slash (e.g. "backup" results in
// /www/htdocs/w0123456/backup). make sure to store nothing else in here because
// old files will be deleted as soon as the quota is met!
$config["backup"]["enabled"] = true; // only disable for testing purposes
$config["backup"]["cleanup"] = true; // disable to never remove any backups
$config["backup"]["target_directory"] = "backup";
$config["backup"]["quota"] = 100 * 1024**3; // in bytes
$config["backup"]["compression_algorithm"] = "gz"; // "gz" = fast, "bz2" = small
// mail settings
// -----------------------------------------------------------------------------
$config["mail"]["enabled"] = true;
$config["mail"]["errors_only"] = false;
$config["mail"]["from"] = "[email protected]";
$config["mail"]["to"] = "[email protected]";
$config["mail"]["subject"] = "Backup complete";
// ftp settings
// -----------------------------------------------------------------------------
$config["ftp"]["enabled"] = false;
$config["ftp"]["unsecure_fallback"] = true; // warning! files can be sent unencrypted
$config["ftp"]["host"] = "ftp.example.com";
$config["ftp"]["port"] = "21";
$config["ftp"]["user"] = "user";
$config["ftp"]["pass"] = "password";
$config["ftp"]["dir"] = "/backups"; // must exist on the server
// locale settings
$config["locale"]["timestamp_format"] = "Y-m-d_H-i-s";
$config["locale"]["date_format"] = "Y-m-d";
$config["locale"]["filename_timestamp_format"] = "Y-m-d";
// sites settings
// -----------------------------------------------------------------------------
// a site is a set of folders and databases that should be archived together.
// to declare multiple sites just copy the settings block like this:
// $sites[] = [...data of site 1...];
// $sites[] = [...data of site 2...];
// - description: a short summary of the site (e.g. "dummy.com main page").
// used for logging purposes.
// - backup_prefix: backup files will use this as a prefix. be sure to include
// only characters a-z, A-Z, 0-9
// and underscores here to be on the safe side.
// - folders: an array of all folders that belong to the site (subfolders are
// included automatically).
// folders are relative to the ftp root directory.
// - databases: an array of all databases that belong to the site.
// - db: database name.
// - user: username. for all-inkl.com this equals the database name.
// - pass: password for the database.
$sites[] = [
"description" => "your-domain.com WordPress",
"backup_prefix" => "your_domain_de",
"folders" => [
"your-domain.de/www"
],
"databases" => [
[ "db" => "d0123456", "user" => "d0123456", "pass" => "password123" ]
]
];
// ########## STOP EDITING HERE (unless you know what you're doing) ##########
The options are largely self-explanatory or commented in the script. Please make sure to update the email address before execution.
Configuration Notes
- The target directory is specified relative to the main directory (/www/htdocs/w0123456/) and must already exist. It therefore needs to be created manually via FTP.
- The script uses the concept of “sites” to organize related folders and databases. A “site” can contain multiple such elements that are backed up together. All folders of a site are compressed into a single archive, while each database is backed up in a separate archive. Each site has a description, such as “phenx.de WordPress”, and a prefix that is prepended to the backup files, such as “phenx_de”.
- To define multiple sites, the
$sites[] = [ ... ]
section in the script can be repeated multiple times. For those unfamiliar with PHP or who usually work with less curious programming languages: This syntax adds a new entry to the end of the array.
Setup
The correctly configured backup.php
file must now be uploaded to all-inkl.com to be executed daily. The following steps explain the process.
- Create a subdomain: First, we create a new subdomain. In this example, I use “backup.phenx.de” (Note: This subdomain is not used productively).

- Create backup directory: In the newly created directory, we use an FTP client to create another directory called “backup”. This is necessary to protect the subdomain with SSL, as Let’s Encrypt cannot access it if the main folder is protected.

- Set up directory protection: Next, we protect the new directory with a username and password. These credentials will later be needed for the cron job to call the script. Manual access via the browser also works with these credentials.

- Set up cron job: As needed, we create a cron job, for example for daily execution. The URL must point to the
cron_backup.php
script. An email address is not required, as the script handles notifications itself.

- Activate SSL certificate: We now protect the page with a Let’s Encrypt SSL certificate. To do this, we go to the “edit” page of the subdomain and then to “SSL protection” - edit. After confirming the terms and conditions, the protection is active.



- Redirect HTTP to HTTPS and activate HSTS: Optionally, we can enable the redirection from HTTP to HTTPS and activate HSTS to enhance security.

- Place backup scripts: Finally, we put the backup scripts in the password-protected directory (identifiable by the
.htaccess
and.htpasswd
files).

- Manual script execution: Now we can call the script manually, in my example at
https://backup.phenx.de/backup/backup.php
. At the prompt, we enter the previously defined user credentials.

The result is displayed both in the browser and via email (screenshots after adding more sites).


Download
The latest version of the script can be found on Github at webhost_backup. To download, simply go to “Code” and select “Download ZIP”.
If you’d like to contribute to the development, feel free to create issues or pull requests on Github. I’ll see them directly there.

No Comments? No Problem.
This blog doesn't support comments, but your thoughts and questions are always welcome. Reach out through the contact details in the footer below.
Support Me
If you found this page helpful and want to say thanks, I would be very grateful if you could use this link for your next purchase on amazon.com. I get a small commission, and it costs you nothing extra. If you'd like to support me in another way, you can find more options here.