Plesk Server Backup Script

Refers to:

  • Plesk

Created:

2016-11-16 13:16:44 UTC

Modified:

2017-02-10 09:11:00 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Plesk Server Backup Script

Release notes

The main goal of the Plesk Server Backup Script is to reduce disk space usage and memory consumption during backup procedures, especially when backing up to the FTP repository.The script makes a backup dump for the entire Plesk server and implements a per-domain backup algorithm as well.

Please feel free to discuss the Plesk Server Backup Script in this special thread on the Plesk Forum .

Run as:

On Unix: php -d safe_mode=0 fullbackup.php
On Windows: "%plesk_bin%\\php" -d auto_prepend_file="" fullbackup.php

Usage:

Backup - output is fullbackup_<datestamp>

-b                                                   Backup to local repository
-b -o <output_dir> Backup to directory
-b -o ftp://<login>:<password>@<server>/<output_dir> Backup to FTP server
-p <backup_password> Set backup password, supported since

Plesk 11 and higher

Export

-e <backup_info_xml> <output_file>                   Export backup from local repository to file

Restore - input is fullbackup_<datestamp>

-r fullbackup_<datestamp>                                   Restore fullbackup_<datestamp>
-r ftp://<login>:<password>@<server>/fullbackup_<datestamp> Restore fullbackup_<datestamp> from FTP

Warning: Restoring functionality of the fullbackup.php is intended for use on the same server only (i.e. server with same IP addresses and overall server configuration). Please feel free to submit requests for improvements on the Plesk Forum .

As a possible scenario, you can use this script in Scheduled Tasks ( Tools & Settings > Tools & Resources > Scheduled Tasks ) for the root user to create a "cronjob" task for a full server backup. (Do not forget to specify the full path in the script command.)

Examples:

./fullbackup.php -b -o <output_dir> -p <passwd>

It backs up whole server storing backup in <output_dir> and protecting backup with password <password> . Password protection encrypts all passwords in backup and such backup can't be restored w/o specifying correct password.

./fullbackup.php -r fullbackup_<datestamp> -p <passwd>

It restores backup created previously by fullbackup.php using specified password.

./fullbackup.php -e /var/lib/psa/dumps/backup_info.xml <output_file>

It exports backup_info.xml with all related files from server local repository to single archive <output_file> . Actually <output_file> is an ordinary Plesk backup archive and later it can be restored in a usual way using pleskrestore utility or via Plesk UI with initial uploading.

Not only server level backup can be exported, but also client or domain level as:

./fullbackup.php -e /var/lib/psa/dumps/clients/<client>/domains/<domain>/domain_backup_info.xml <output_file>

How to restore backups on the other server:

Backup exporting is required if you want to restore these backups on another server. Plesk creates backups in local repository with passwords encrypted by Plesk encryption key. Another Plesk has different encryption key, so these backups can't be restored . Exporting is the same operation as downloading backup from Plesk UI or uploading backup to FTP repository - it decrypts passwords and stores them in plain text.

Best practise in this case is to have external FTP repository and store backups on it. In case of disaster and full server unavailability it will allow you to restore backups on new Plesk Panel server with minimum time and business impact.

Additional information :

Now fullbackup.php has following heading:

#!/usr/local/psa/bin/sw-engine-pleskrun

It means that it can be executed directly as:

./fullbackup.php

because interpreter is set to /usr/local/psa/bin/sw-engine-pleskrun automatically.

Command:

# chmod u+x fullbackup.php

is required for proper script execution.

Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Win Techs

    Hi

     

    How can we automate.

    Export

    -e <backup_info_xml> <output_file> Export backup from local repository to file

    I would like to retrieve latest xml from server / client repository and export them to UNC path with same xml name used as zip

    example
    "%plesk_bin%\php" -d auto_prepend_file="" C:\fullbackup.php -e %XML_varible% \\UNC\Name_Extract_from_XML.zip

    My task would be to achieve export from local repository directly to remote as not use another backup run.


     

  • 0
    Avatar
    Nikolay Zhmuk

    Hi, it is not possible to achieve such goal by Plesk functionality. However, this is possible to configure FTP repository as a remote backup storage:

    https://docs.plesk.com/en-US/onyx/administrator-guide/backing-up-and-restoration/using-an-ftp-storage.59259/

Please sign in to leave a comment.