• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How to create two backup tasks

ngelG

Basic Pleskian
Hi all.

I see I can only create a single backup task in plesk, server self repository or ftp repository.

My idea is duplicate backups inside and outside of my vps, I mean, I want to create a backup task in my vps and in my own ftp server.

It is posible?

Thanks!
 
well... I wouldn't declare this as impossible.

Plesk has as well an optional "Plesk Server Backup Script" which you can download here ( at the bottom of the KB - article ):

Plesk Server Backup Script ( KB - article: 113 252 )

**************************************************
Short installation and example usage, taken from the KB - article and modified in the "right" order:

  • Create a folder in the root - drectory and move to the just created folder:
mkdir /root/Backup_script && cd /root/Backup_script
  • Download the Plesk Server Backup Script script:
  • Make the "Plesk Server Backup Script" executable:
chmod u+x fullbackup.php

  • Please create an additional PHP.ini, which you will use only for the backups with the Plesk Server Backup Script, because the following settings are quite insecure for a global PHP.ini setting, but these settings are needed by the script, in order to work with the external FTP server:
mkdir /etc/php5/Backup
cp /etc/php5/cli/php.ini /etc/php5/Backup/php.ini

( Please correct the path to copy the cli - php.ini, with your own operating system settings... "etc/php/" - "/etc/php5/" "/etc/path/to/your/cli/php.ini" )
  • Make sure, that you set these two options in your just copied PHP.ini at: /etc/php5/Backup/php.ini
PHP:
allow_url_include = On
allow_url_fopen = On

  • Here are some optional PHP - settings, which might help to avoid issues/problems/errors, but modify the date settings according to your OWN location, please:
PHP:
max_execution_time = 360
max_input_time = 360
memory_limit = 256M
post_max_size = 256M
include_path = ".:/tmp:/var/tmp:/bin:/usr/bin:/usr/local/bin:/usr/local/psa:/usr/share/php:/usr/share/php5:/usr/share/perl:/usr/share/perl5:/usr/bin/python:/usr/bin/python3:/etc/psa:/usr/share/psa-pear"
cgi.fix_pathinfo=0
default_socket_timeout = 360
; http://php.net/date.timezone
date.timezone = "Europe/Berlin"
; http://php.net/date.default-latitude
date.default_latitude = 52.5194
; http://php.net/date.default-longitude
date.default_longitude = 13.4067

  • To execute the script from the command line, use the following example:
cd /root/Backup_script
php -c /etc/php5/Backup/php.ini -d safe_mode=0 fullbackup.php -b

-b defines automatically the backup being stored to the local repository, so it will be listed over the Plesk Control Panel
-b -o <output_dir> Backup to a desired directory on your server - - - Example: ./fullbackup.php -b -o /root/BackUps
-b -o ftp://<login>:<password>@<server>/<output_dir> Backup to a FTP server - - - Example: ./fullbackup.php -b -o ftp://<login>:<password>@<server>/<output_dir>
-p <backup_password> Set a desired backup password - - - Example: ./fullbackup.php -b -p <backup_password>

( be aware that only the correct password will restore the backups - all paswwords in the backup are encrypted with this option! )
--per-domain Backup per domain, default - all server at once - - - Example: ./fullbackup.php -b --per-domain


Note that your local repository is defined in:
/etc/psa/psa.conf
To show the defined location on YOUR system, please use the command:
grep DUMP_D /etc/psa/psa.conf


Please read the KB - article 113 252 to restore the Backups, using this Plesk Server Backup Script and be aware,
that these backups are only valid on the same server with the same IPs and same overall configuration.

Additional informations to restore a backup, are located in the Plesk 12 Online documentation at:
Defining Objects for Restoration ( Plesk 12 Online documentation )



  • Configure a daily/weekly/monthly/yearly cronjob over the Plesk Control Panel: Tools & Settings > Tools & Resources > Scheduled Tasks
Do not forget to define the above possible commands with the correct path and add a cronjob for the user "root"... for example:

php -c /etc/php5/Backup/php.ini
-d safe_mode=0 /root/Backup_script/fullbackup.php -b -p <backup_password>
php -c /etc/php5/Backup/php.ini -d safe_mode=0 /root/Backup_script/fullbackup.php -b -p <backup_password> -o ftp://<login>:<password>@<server>/<output_dir>

**************************************************
Additional notes:
The Plesk Server Backup Script creates a FULL server backup, so make sure, that you have at least twice as much space available, than your local backups will be ( as *tar.gz ), because the scriipt uses as well the temp folder to create the backiups and each webserver has to have some space left... so please don't use the script, if you are unsure, if the free space will be sufficient on your local hdd and/or external FTP server!

The script may cause errors with large domains, which are not yet all solved!


Be aware that there is no option to define a maximum number of backups with the Plesk Server Backup Script. This means, that you have to delete "old" backups manually, in order to guarantee, that the local disk and/or the FTP server won't be filled up with useless backups. You could set another cronjob as well, to delete the files older than X days, if a defined maximum number of backup - files is reached. An example for such a bash script would look like this:
  • Create a file with the command:
touch /root/Backup_script/daily_cleanup.sh

  • Edit the file /root/Backup_script/daily_cleanup.sh ( please modify it with YOUR PATH and YOUR minimum number of files - "MINDIRS" - and define as well YOUR mtime - "+7" - definition )
HTML:
#!/bin/bash

COUNT=`/bin/ls -l /root/BackUPs | /usr/bin/wc -l`
MINDIRS=7

if [[ $COUNT -gt $MINDIRS ]]
    then
    /usr/bin/find /root/BackUPs -type d -mtime +7 -exec rm -rf {} ;
else
    echo LIMIT NOT YET REACHED
fi
  • Make the daily_cleanup.sh executable:
chmod u+x /root/Backup_script/daily_cleanup.sh
  • Configure a daily cronjob over the Plesk Control Panel: Tools & Settings > Tools & Resources > Scheduled Tasks
Add a daily cronjob for the user "root"... for example:

/root/Backup_script/daily_cleanup.sh > /var/log/daily_cleanup.log


You could use "CurlFtpFS" if you would like do the same daily_cleanup as a cronjob on your FTP - server, but the reason why I don't suggest this is the fact, that you have to mount the whole used FTP - space on your local hdd if you use CurlFtpFS and this is mostly not possible, due to space problems. My suggestion for a daily_cleanup on a Backup - FTP - server is still the manual way deleting the files... it only takes a few seconds to do that, so do it, while you drink your first coffee, check your eMails and connect to your Backup - FTP - Server at the same time. ^^

**************************************************

You might discuss the usage of the script here:


... and in case of issues/failures/problems you could provide as well your used php.ini, your log - files from "/var/log/plesk/PMM/ACTUAL_BACKUP_WITH_DATE_AND_TIMESTAMP/" ( please only add the errors/issues from the logs, because these files can be rather long and may contain sensible data) and you could as well add your operating system and your current Plesk - version ( incl. MU ), so that further investigations are easier for the people willing to help. :)
 
Back
Top