Skip to content

Instantly share code, notes, and snippets.

@matteomattei
Last active June 16, 2021 07:36
Show Gist options
  • Save matteomattei/cf0dabd87aa34fd4d10a to your computer and use it in GitHub Desktop.
Save matteomattei/cf0dabd87aa34fd4d10a to your computer and use it in GitHub Desktop.
A simple script to backup Plesk server and store data in a remote FTP
#!/bin/bash
set -e
FTP_USER="ftp_user"
FTP_PASS="ftp_password"
FTP_HOST="ftp_host"
# REMOVE BACKUPS OLDER THAN 7 DAYS
FILES=$(lftp -e 'cd pleskbackup; cls --sort="date"; exit;' -u ${FTP_USER},${FTP_PASS} ${FTP_HOST})
if [ $(echo "${FILES}" | wc -l) -gt 7 ];
then
FILE_TO_REMOVE=$(echo "${FILES}" | head -n1)
lftp -e "cd pleskbackup; rm -f ${FILE_TO_REMOVE}; exit;" -u ${FTP_USER},${FTP_PASS} ${FTP_HOST}
fi
/usr/local/psa/bin/pleskbackup server --skip-logs --output-file=ftp://${FTP_USER}:${FTP_PASS}@${FTP_HOST}/pleskbackup/`date +%F`_full_psa_backup.raw
@sfnemis
Copy link

sfnemis commented Jun 15, 2021

line 9: lftp: command not found on Plesk Version 18.0.36

@matteomattei
Copy link
Author

You have to manually install lftp:

apt install lftp for Debian/Ubuntu
yum install lftp for RedHat/CentOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment